Skip to content
Snippets Groups Projects
Commit 36b6d305 authored by George Nachman's avatar George Nachman
Browse files

Improve docstrings for hierarchy.py

parent 73ea4956
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -12,7 +12,7 @@ import tab
import window
import logging
 
class Synchronizer(object):
class _Synchronizer(object):
def __init__(self):
notifications.NewSessionSubscription(lambda notification: self._refresh())
notifications.TerminateSessionSubscription(lambda notification: self._refresh())
Loading
Loading
@@ -36,11 +36,13 @@ class Synchronizer(object):
return None
 
class Hierarchy(object):
"""Stores a representation of iTerm2's window-tab-session hierarchy. Also used to create new windows."""
def __init__(self):
self.synchronizer = Synchronizer()
self.synchronizer = _Synchronizer()
self.windows = None
 
def pretty_str(self):
"""Returns the hierarchy as a human-readable string"""
s = ""
for w in self.get_windows():
if len(s) > 0:
Loading
Loading
@@ -49,12 +51,26 @@ class Hierarchy(object):
return s
 
def get_windows(self):
"""Gets the current windows.
Returns:
An array of Window objects."""
newValue = self.synchronizer.get()
if newValue is not None:
self.parse(newValue)
self._parse(newValue)
return self.windows
 
def parse(self, response):
def create_window(self, profile=None, command=None):
"""Creates a new window.
Arguments;
profile: The name of the profile to use for the window's first session. If None, the default profile will be used.
command: A command to run in lieu of the default command or login shell, if not None.
"""
return window.FutureWindow(get_socket().request_create_tab(
profile=profile, window=None, index=None, command=command))
def _parse(self, response):
windows = []
for w in response.windows:
tabs = []
Loading
Loading
@@ -66,10 +82,6 @@ class Hierarchy(object):
windows.append(window.Window(w.window_id, tabs))
self.windows = windows
 
def create_window(self, profile=None, command=None):
return window.FutureWindow(get_socket().request_create_tab(
profile=profile, window=None, index=None, command=command))
def __repr__(self):
return "<Hierarchy windows=%s>" % self.get_windows()
 
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment