@@ -96,15 +96,18 @@ def tmux(self, *args, **kwargs):
96
96
97
97
return tmux (* args , ** kwargs )
98
98
99
- def __list_sessions (self ):
100
- """Return list of ``$ tmux(1) list-sessions`` stdout.
99
+ def _list_sessions (self ):
100
+ """Return a list of session information ``tmux(1)`` for the sessions.
101
+
102
+ Via ``$ tmux(1) list-sessions`` stdout.
101
103
102
104
The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux`
103
105
which wraps :py:meth:`Subprocess.Popen`.
104
106
105
- :rtype: list
107
+ :rtype: :py:obj:` list` of :py:obj:`dict`
106
108
107
109
"""
110
+
108
111
sformats = formats .SESSION_FORMATS
109
112
tmux_formats = ['#{%s}' % f for f in sformats ]
110
113
@@ -123,20 +126,11 @@ def __list_sessions(self):
123
126
session_info = proc .stdout [0 ]
124
127
125
128
if proc .stderr :
126
- raise Exception (sessions .stderr )
127
-
128
- return proc .stdout
129
-
130
- def _list_sessions (self ):
131
- '''
132
- Return a list of session information ``tmux(1)`` for the sessions
133
-
134
- :rtype: :py:obj:`list` of :py:obj:`dict`
135
- '''
129
+ raise Exception (proc .stderr )
136
130
137
131
sformats = formats .SESSION_FORMATS
138
132
tmux_formats = ['#{%s}' % format for format in sformats ]
139
- sessions = self . __list_sessions ()
133
+ sessions = proc . stdout
140
134
141
135
# combine format keys with values returned from ``tmux list-windows``
142
136
sessions = [dict (zip (
@@ -176,8 +170,10 @@ def sessions(self):
176
170
#: Alias of :attr:`sessions`.
177
171
children = sessions
178
172
179
- def __list_windows (self ):
180
- """Return list of ``$ tmux(1) list-windows`` stdout.
173
+ def _list_windows (self ):
174
+ """Return list of dicts filtered from :meth:`__list_windows`.
175
+
176
+ List of ``$ tmux(1) list-windows`` stdout.
181
177
182
178
The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux`
183
179
which wraps :py:meth:`Subprocess.Popen`.
@@ -189,24 +185,19 @@ def __list_windows(self):
189
185
wformats = ['session_name' , 'session_id' ] + formats .WINDOW_FORMATS
190
186
tmux_formats = ['#{%s}' % format for format in wformats ]
191
187
192
- windows = self .tmux (
188
+ proc = self .tmux (
193
189
'list-windows' , # ``tmux list-windows``
194
190
'-a' ,
195
191
'-F%s' % '\t ' .join (tmux_formats ), # output
196
192
)
197
193
198
- if windows .stderr :
199
- raise Exception (windows .stderr )
200
-
201
- return windows .stdout
194
+ if proc .stderr :
195
+ raise Exception (proc .stderr )
202
196
203
- def _list_windows (self ):
204
- """Return list of dicts filtered from :meth:`__list_windows`."""
197
+ windows = proc .stdout
205
198
206
199
wformats = ['session_name' , 'session_id' ] + formats .WINDOW_FORMATS
207
200
208
- windows = self .__list_windows ()
209
-
210
201
# combine format keys with values returned from ``tmux list-windows``
211
202
windows = [dict (zip (
212
203
wformats , window .split ('\t ' ))) for window in windows ]
@@ -238,39 +229,36 @@ def _update_windows(self):
238
229
self ._list_windows ()
239
230
return self
240
231
241
- def __list_panes (self ):
242
- """Return list of ``$ tmux(1) list-panes`` stdout.
232
+ def _list_panes (self ):
233
+ """Return list of dicts filtered from :meth:`__list_panes`.
234
+
235
+ list of ``$ tmux(1) list-panes`` stdout.
243
236
244
237
The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux`
245
238
which wraps :py:meth:`Subprocess.Popen`.
246
239
247
-
248
240
:rtype: list
249
241
250
242
"""
243
+
251
244
pformats = ['session_name' , 'session_id' ,
252
245
'window_index' , 'window_id' , 'window_name' ] + formats .PANE_FORMATS
253
246
tmux_formats = ['#{%s}\t ' % f for f in pformats ]
254
247
255
- panes = self .tmux (
248
+ proc = self .tmux (
256
249
'list-panes' ,
257
250
'-a' ,
258
251
'-F%s' % '' .join (tmux_formats ), # output
259
252
)
260
253
261
- if panes .stderr :
262
- raise Exception (panes .stderr )
263
-
264
- return panes .stdout
254
+ if proc .stderr :
255
+ raise Exception (proc .stderr )
265
256
266
- def _list_panes (self ):
267
- """Return list of dicts filtered from :meth:`__list_panes`."""
257
+ panes = proc .stdout
268
258
269
259
pformats = ['session_name' , 'session_id' ,
270
260
'window_index' , 'window_id' , 'window_name' ] + formats .PANE_FORMATS
271
261
272
- panes = self .__list_panes ()
273
-
274
262
# combine format keys with values returned from ``tmux list-panes``
275
263
panes = [dict (zip (
276
264
pformats , window .split ('\t ' ))) for window in panes ]
0 commit comments