raise the correct exception if methods are called from the base class that must be overridden by subclasses. Remove unnecessary dependencies and achieve 10/10 from pylint
This commit is contained in:
parent
598eededd2
commit
adb1c2a1f8
|
@ -4,11 +4,9 @@
|
||||||
"""container.py - classes necessary to contain Terminal widgets"""
|
"""container.py - classes necessary to contain Terminal widgets"""
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
|
||||||
|
|
||||||
from util import debug, err
|
# pylint: disable-msg=R0921
|
||||||
|
class Container(object):
|
||||||
class Container():
|
|
||||||
"""Base class for Terminator Containers"""
|
"""Base class for Terminator Containers"""
|
||||||
|
|
||||||
immutable = None
|
immutable = None
|
||||||
|
@ -32,15 +30,19 @@ class Container():
|
||||||
self.children = []
|
self.children = []
|
||||||
self.config = configobject
|
self.config = configobject
|
||||||
|
|
||||||
def register_signals(self, object):
|
def register_signals(self, widget):
|
||||||
"""Register gobject signals in a way that avoids multiple inheritance"""
|
"""Register gobject signals in a way that avoids multiple inheritance"""
|
||||||
for signal in self.signals:
|
for signal in self.signals:
|
||||||
gobject.signal_new(signal['name'],
|
gobject.signal_new(signal['name'],
|
||||||
object,
|
widget,
|
||||||
signal['flags'],
|
signal['flags'],
|
||||||
signal['return_type'],
|
signal['return_type'],
|
||||||
signal['param_types'])
|
signal['param_types'])
|
||||||
|
|
||||||
|
def emit(self, signal):
|
||||||
|
"""Emit a gobject signal"""
|
||||||
|
raise NotImplementedError('emit')
|
||||||
|
|
||||||
def get_offspring(self):
|
def get_offspring(self):
|
||||||
"""Return a list of child widgets, if any"""
|
"""Return a list of child widgets, if any"""
|
||||||
return(self.children)
|
return(self.children)
|
||||||
|
@ -55,17 +57,15 @@ class Container():
|
||||||
|
|
||||||
def split_axis(self, widget, vertical=True):
|
def split_axis(self, widget, vertical=True):
|
||||||
"""Default axis splitter. This should be implemented by subclasses"""
|
"""Default axis splitter. This should be implemented by subclasses"""
|
||||||
err('split_axis called from base class. This is a bug')
|
raise NotImplementedError('split_axis')
|
||||||
return(False)
|
|
||||||
|
|
||||||
def unsplit(self, widget, keep=False):
|
def unsplit(self, widget, keep=False):
|
||||||
"""Default unsplitter. This should be implemented by subclasses"""
|
"""Default unsplitter. This should be implemented by subclasses"""
|
||||||
err('unsplit called from base class. This is a bug')
|
raise NotImplementedError('unsplit')
|
||||||
return(False)
|
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
"""Remove a widget from the container"""
|
"""Remove a widget from the container"""
|
||||||
err('remove called from base class. This is a bug')
|
raise NotImplementedError('remove')
|
||||||
|
|
||||||
def closeterm(self, widget):
|
def closeterm(self, widget):
|
||||||
"""Handle the closure of a terminal"""
|
"""Handle the closure of a terminal"""
|
||||||
|
@ -78,22 +78,9 @@ class Container():
|
||||||
self.emit('need_group_hoover')
|
self.emit('need_group_hoover')
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def closegroupterms(self, widget):
|
|
||||||
"""Handle the closure of a group of terminals"""
|
|
||||||
if self.state_zoomed != self.states_zoom['normal']:
|
|
||||||
self.unzoom(widget)
|
|
||||||
|
|
||||||
all_closed = True
|
|
||||||
for term in self.term_list[:]:
|
|
||||||
if term._group == widget._group and not self.remove(term):
|
|
||||||
all_closed = False
|
|
||||||
|
|
||||||
self.emit('need_group_hoover')
|
|
||||||
return(all_closed)
|
|
||||||
|
|
||||||
def resizeterm(self, widget, keyname):
|
def resizeterm(self, widget, keyname):
|
||||||
"""Handle a keyboard event requesting a terminal resize"""
|
"""Handle a keyboard event requesting a terminal resize"""
|
||||||
err('resizeterm called from base class. This is a bug')
|
raise NotImplementedError('resizeterm')
|
||||||
|
|
||||||
def toggle_zoom(self, widget, fontscale = False):
|
def toggle_zoom(self, widget, fontscale = False):
|
||||||
"""Toggle the existing zoom state"""
|
"""Toggle the existing zoom state"""
|
||||||
|
@ -104,10 +91,14 @@ class Container():
|
||||||
|
|
||||||
def zoom(self, widget, fontscale = False):
|
def zoom(self, widget, fontscale = False):
|
||||||
"""Zoom a terminal"""
|
"""Zoom a terminal"""
|
||||||
err('zoom called from base class. This is a bug')
|
raise NotImplementedError('zoom')
|
||||||
|
|
||||||
def unzoom(self, widget):
|
def unzoom(self, widget):
|
||||||
"""Unzoom a terminal"""
|
"""Unzoom a terminal"""
|
||||||
err('unzoom called from base class. This is a bug')
|
raise NotImplementedError('unzoom')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
CONTAINER = Container()
|
||||||
|
CONTAINER.zoom()
|
||||||
|
|
||||||
# vim: set expandtab ts=4 sw=4:
|
# vim: set expandtab ts=4 sw=4:
|
||||||
|
|
Loading…
Reference in New Issue