Skip to content

Commit 7779215

Browse files
committed
fix attribute lookups, get freshed results from _info
1 parent 7a67d62 commit 7779215

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

libtmux/common.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ def __iter__(self):
224224
def __len__(self):
225225
return len(self._info.keys())
226226

227-
# def __getattr__(self, key):
228-
# try:
229-
# return self[key]
230-
# except KeyError:
231-
# return super(self, TmuxMappingObject).__getattr__(key)
227+
def __getattr__(self, key):
228+
try:
229+
return self._info[self.formatter_prefix + key]
230+
except:
231+
raise AttributeError
232232

233233

234234
class TmuxRelationalObject(object):
@@ -317,12 +317,6 @@ def get_by_id(self, id):
317317

318318
return None
319319

320-
def __getattr__(self, key):
321-
try:
322-
return self[self.formatter_prefix + key]
323-
except:
324-
raise AttributeError
325-
326320

327321
def which(exe=None):
328322
"""Return path of bin. Python clone of /usr/bin/which.

libtmux/pane.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Pane(TmuxMappingObject, TmuxRelationalObject):
2626
Renamed from ``.tmux`` to ``.cmd``.
2727
2828
"""
29-
formatter_prefix = 'pane'
29+
formatter_prefix = 'pane_'
3030

3131
def __init__(self, window=None, **kwargs):
3232
if not window:

libtmux/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Session(
3030
"""
3131

3232
child_id_attribute = 'window_id'
33-
formatter_prefix = 'session'
33+
formatter_prefix = 'session_'
3434

3535
def __init__(self, server=None, **kwargs):
3636
EnvironmentMixin.__init__(self)

libtmux/window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Window(TmuxMappingObject, TmuxRelationalObject):
2222
""":term:`tmux(1)` window."""
2323

2424
child_id_attribute = 'pane_id'
25-
formatter_prefix = 'window'
25+
formatter_prefix = 'window_'
2626

2727
def __init__(self, session=None, **kwargs):
2828

0 commit comments

Comments
 (0)