[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [nyx/master] Move header_panel method
commit 07432edae044bb5e71b16e2cd994ef9fbc89ad42
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Thu Sep 15 12:46:47 2016 -0700
Move header_panel method
Moving our last method and dropping the get_* prefix from the other panel
methods.
---
nyx/__init__.py | 26 ++++++++++++++++++--------
nyx/controller.py | 7 ++-----
nyx/menu.py | 4 ++--
nyx/popups.py | 2 +-
test/popups.py | 2 +-
5 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/nyx/__init__.py b/nyx/__init__.py
index dc4d3e5..973776d 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -19,8 +19,9 @@ Tor curses monitoring application.
|- set_page - sets the page we're showing
|- page_count - pages within our interface
|
- |- get_page_panels - provides panels on a page
- |- get_daemon_panels - provides daemon panels
+ |- header_panel - provides the header panel
+ |- page_panels - provides panels on a page
+ |- daemon_panels - provides daemon panels
|
|- is_paused - checks if the interface is paused
|- set_paused - sets paused state
@@ -268,7 +269,16 @@ class Interface(object):
return len(self._page_panels)
- def get_page_panels(self, page_number = None):
+ def header_panel(self):
+ """
+ Provides our interface's header.
+
+ :returns: :class:`~nyx.panel.header.HeaderPanel` of our interface
+ """
+
+ return self._header_panel
+
+ def page_panels(self, page_number = None):
"""
Provides panels belonging to a page, ordered top to bottom.
@@ -280,7 +290,7 @@ class Interface(object):
return list(self._page_panels[self._page if page_number is None else page_number])
- def get_daemon_panels(self):
+ def daemon_panels(self):
"""
Provides panels that are daemons.
@@ -312,7 +322,7 @@ class Interface(object):
for panel in self:
panel.set_paused(is_pause)
- for panel in self.get_page_panels():
+ for panel in self.page_panels():
panel.redraw()
def redraw(self, force = True):
@@ -331,7 +341,7 @@ class Interface(object):
occupied = 0
- for panel in [self.header_panel()] + self.get_page_panels():
+ for panel in [self.header_panel()] + self.page_panels():
panel.redraw(force = force, top = occupied)
occupied += panel.get_height()
@@ -350,10 +360,10 @@ class Interface(object):
"""
def halt_panels():
- for panel in self.get_daemon_panels():
+ for panel in self.daemon_panels():
panel.stop()
- for panel in self.get_daemon_panels():
+ for panel in self.daemon_panels():
panel.join()
halt_thread = threading.Thread(target = halt_panels)
diff --git a/nyx/controller.py b/nyx/controller.py
index 201dec4..cb69082 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -129,9 +129,6 @@ class Controller(Interface):
if CONFIG['features.panels.show.interpreter']:
self._page_panels.append([nyx.panel.interpreter.InterpreterPanel()])
- def header_panel(self):
- return self._header_panel
-
def start_nyx():
"""
@@ -151,7 +148,7 @@ def start_nyx():
# tells daemon panels to start
- for panel in interface.get_daemon_panels():
+ for panel in interface.daemon_panels():
panel.start()
# logs the initialization time
@@ -163,7 +160,7 @@ def start_nyx():
override_key = None # uses this rather than waiting on user input
while not interface._quit:
- display_panels = [interface.header_panel()] + interface.get_page_panels()
+ display_panels = [interface.header_panel()] + interface.page_panels()
# sets panel visability
diff --git a/nyx/menu.py b/nyx/menu.py
index ebb8305..4d5f61c 100644
--- a/nyx/menu.py
+++ b/nyx/menu.py
@@ -240,7 +240,7 @@ def _make_menu():
root_menu.add(_view_menu())
- for panel in interface.get_page_panels():
+ for panel in interface.page_panels():
submenu = panel.submenu()
if submenu:
@@ -270,7 +270,7 @@ def _view_menu():
page_group = RadioGroup(interface.set_page, interface.get_page())
for i in range(interface.page_count()):
- page_panels = interface.get_page_panels(page_number = i)
+ page_panels = interface.page_panels(page_number = i)
label = ' / '.join([type(panel).__name__.replace('Panel', '') for panel in page_panels])
view_menu.add(RadioMenuItem(label, page_group, i))
diff --git a/nyx/popups.py b/nyx/popups.py
index b52d95d..e2f0205 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -59,7 +59,7 @@ def show_help():
interface = nyx_interface()
handlers = []
- for panel in reversed(interface.get_page_panels()):
+ for panel in reversed(interface.page_panels()):
handlers += [handler for handler in panel.key_handlers() if handler.description]
def _render(subwindow):
diff --git a/test/popups.py b/test/popups.py
index 361d15b..3e64914 100644
--- a/test/popups.py
+++ b/test/popups.py
@@ -275,7 +275,7 @@ class TestPopups(unittest.TestCase):
nyx.panel.KeyHandler('c', 'clear event log'),
)
- nyx_interface_mock().get_page_panels.return_value = [header_panel, graph_panel, log_panel]
+ nyx_interface_mock().page_panels.return_value = [header_panel, graph_panel, log_panel]
rendered = test.render(nyx.popups.show_help)
self.assertEqual(EXPECTED_HELP_POPUP, rendered.content)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits