Skip to content

Commit

Permalink
Merge pull request #576 from Vulcalien/fix-dbg-messages
Browse files Browse the repository at this point in the history
Remove duplicated info in some debug messages
  • Loading branch information
mattrose authored Jan 29, 2022
2 parents 80ce461 + 8e50eb7 commit fc528b2
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 76 deletions.
3 changes: 1 addition & 2 deletions terminatorlib/borg.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ def __init__(self, borgtype=None):
if borgtype is None:
raise TypeError('Borg::__init__: You must pass a borgtype')
if borgtype not in self.__shared_state:
dbg('Borg::__init__: Preparing borg state for %s' % borgtype)
dbg('Preparing borg state for %s' % borgtype)
self.__shared_state[borgtype] = {}
self.__dict__ = self.__shared_state[borgtype]

def prepare_attributes(self):
"""This should be used to prepare any attributes of the borg class."""
raise NotImplementedError('prepare_attributes')

40 changes: 18 additions & 22 deletions terminatorlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ def set_profile(self, profile, force=False):
if not force and options and options.profile and profile == 'default':
dbg('overriding default profile to %s' % options.profile)
profile = options.profile
dbg('Config::set_profile: Changing profile to %s' % profile)
dbg('Changing profile to %s' % profile)
self.profile = profile
if profile not in self.base.profiles:
dbg('Config::set_profile: %s does not exist, creating' % profile)
dbg('%s does not exist, creating' % profile)
self.base.profiles[profile] = copy(DEFAULTS['profiles']['default'])

def add_profile(self, profile, toclone):
Expand Down Expand Up @@ -617,7 +617,7 @@ def defaults_to_configspec(self):
def load(self):
"""Load configuration data from our various sources"""
if self.loaded is True:
dbg('ConfigBase::load: config already loaded')
dbg('config already loaded')
return

if self.command_line_options and self.command_line_options.config:
Expand Down Expand Up @@ -665,11 +665,11 @@ def load(self):
dbg('config validated successfully')

for section_name in self.sections:
dbg('ConfigBase::load: Processing section: %s' % section_name)
dbg('Processing section: %s' % section_name)
section = getattr(self, section_name)
if section_name == 'profiles':
for profile in parser[section_name]:
dbg('ConfigBase::load: Processing profile: %s' % profile)
dbg('Processing profile: %s' % profile)
if section_name not in section:
# FIXME: Should this be outside the loop?
section[profile] = copy(DEFAULTS['profiles']['default'])
Expand All @@ -678,13 +678,11 @@ def load(self):
if section_name not in parser:
continue
for part in parser[section_name]:
dbg('ConfigBase::load: Processing %s: %s' % (section_name,
part))
dbg('Processing %s: %s' % (section_name, part))
section[part] = parser[section_name][part]
elif section_name == 'layouts':
for layout in parser[section_name]:
dbg('ConfigBase::load: Processing %s: %s' % (section_name,
layout))
dbg('Processing %s: %s' % (section_name, layout))
if layout == 'default' and \
parser[section_name][layout] == {}:
continue
Expand All @@ -693,8 +691,7 @@ def load(self):
if section_name not in parser:
continue
for part in parser[section_name]:
dbg('ConfigBase::load: Processing %s: %s' % (section_name,
part))
dbg('Processing %s: %s' % (section_name, part))
if parser[section_name][part] == 'None':
section[part] = None
else:
Expand All @@ -703,8 +700,7 @@ def load(self):
try:
section.update(parser[section_name])
except KeyError as ex:
dbg('ConfigBase::load: skipping missing section %s' %
section_name)
dbg('skipping missing section %s' % section_name)

self.loaded = True

Expand All @@ -715,12 +711,12 @@ def reload(self):

def save(self):
"""Save the config to a file"""
dbg('ConfigBase::save: saving config')
dbg('saving config')
parser = ConfigObj(encoding='utf-8')
parser.indent_type = ' '

for section_name in ['global_config', 'keybindings']:
dbg('ConfigBase::save: Processing section: %s' % section_name)
dbg('Processing section: %s' % section_name)
section = getattr(self, section_name)
parser[section_name] = dict_diff(DEFAULTS[section_name], section)

Expand All @@ -730,20 +726,20 @@ def save(self):
for profile in self.profiles:
if profile == JSON_PROFILE_NAME:
continue
dbg('ConfigBase::save: Processing profile: %s' % profile)
dbg('Processing profile: %s' % profile)
parser['profiles'][profile] = dict_diff(
DEFAULTS['profiles']['default'], self.profiles[profile])

parser['layouts'] = {}
for layout in self.layouts:
if layout == JSON_LAYOUT_NAME:
continue
dbg('ConfigBase::save: Processing layout: %s' % layout)
dbg('Processing layout: %s' % layout)
parser['layouts'][layout] = self.layouts[layout]

parser['plugins'] = {}
for plugin in self.plugins:
dbg('ConfigBase::save: Processing plugin: %s' % plugin)
dbg('Processing plugin: %s' % plugin)
parser['plugins'][plugin] = self.plugins[plugin]

config_dir = get_config_dir()
Expand Down Expand Up @@ -776,17 +772,17 @@ def get_item(self, key, profile='default', plugin=None, default=None):
profile = 'default'

if key in self.global_config:
dbg('ConfigBase::get_item: %s found in globals: %s' %
dbg('%s found in globals: %s' %
(key, self.global_config[key]))
return(self.global_config[key])
elif key in self.profiles[profile]:
dbg('ConfigBase::get_item: %s found in profile %s: %s' % (
dbg('%s found in profile %s: %s' % (
key, profile, self.profiles[profile][key]))
return(self.profiles[profile][key])
elif key == 'keybindings':
return(self.keybindings)
elif plugin and plugin in self.plugins and key in self.plugins[plugin]:
dbg('ConfigBase::get_item: %s found in plugin %s: %s' % (
dbg('%s found in plugin %s: %s' % (
key, plugin, self.plugins[plugin][key]))
return(self.plugins[plugin][key])
elif default:
Expand All @@ -796,7 +792,7 @@ def get_item(self, key, profile='default', plugin=None, default=None):

def set_item(self, key, value, profile='default', plugin=None):
"""Set a configuration item"""
dbg('ConfigBase::set_item: Setting %s=%s (profile=%s, plugin=%s)' %
dbg('Setting %s=%s (profile=%s, plugin=%s)' %
(key, value, profile, plugin))

if key in self.global_config:
Expand Down
4 changes: 2 additions & 2 deletions terminatorlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ def closeterm(self, widget):
try:
if self.get_property('term_zoomed'):
# We're zoomed, so unzoom and then start closing again
dbg('Container::closeterm: terminal zoomed, unzooming')
dbg('terminal zoomed, unzooming')
self.unzoom(widget)
widget.close()
return(True)
except TypeError:
pass

if not self.remove(widget):
dbg('Container::closeterm: self.remove() failed for %s' % widget)
dbg('self.remove() failed for %s' % widget)
return(False)

self.terminator.deregister_terminal(widget)
Expand Down
3 changes: 1 addition & 2 deletions terminatorlib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def make(self, product, **kwargs):
err('Factory::make: requested object does not exist: %s' % product)
return(None)

dbg('Factory::make: created a %s' % product)
dbg('created a %s' % product)
output = func(**kwargs)
inject_uuid(output)
return(output)
Expand Down Expand Up @@ -118,4 +118,3 @@ def make_notebook(self, **kwargs):
"""Make a Notebook"""
from . import notebook
return(notebook.Notebook(kwargs['window']))

12 changes: 6 additions & 6 deletions terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=N

def wrapcloseterm(self, widget):
"""A child terminal has closed"""
dbg('Notebook::wrapcloseterm: called on %s' % widget)
dbg('called on %s' % widget)
if self.closeterm(widget):
dbg('Notebook::wrapcloseterm: closeterm succeeded')
dbg('closeterm succeeded')
self.hoover()
else:
dbg('Notebook::wrapcloseterm: closeterm failed')
dbg('closeterm failed')

def closetab(self, widget, label):
"""Close a tab"""
Expand All @@ -371,15 +371,15 @@ def closetab(self, widget, label):
child = nb.get_nth_page(tabnum)

if maker.isinstance(child, 'Terminal'):
dbg('Notebook::closetab: child is a single Terminal')
dbg('child is a single Terminal')
del nb.last_active_term[child]
child.close()
# FIXME: We only do this del and return here to avoid removing the
# page below, which child.close() implicitly does
del(label)
return
elif maker.isinstance(child, 'Container'):
dbg('Notebook::closetab: child is a Container')
dbg('child is a Container')
result = self.construct_confirm_close(self.window, _('tab'))

if result == Gtk.ResponseType.ACCEPT:
Expand All @@ -394,7 +394,7 @@ def closetab(self, widget, label):
Gtk.main_iteration()
return
else:
dbg('Notebook::closetab: user cancelled request')
dbg('user cancelled request')
return
else:
err('Notebook::closetab: child is unknown type %s' % child)
Expand Down
2 changes: 1 addition & 1 deletion terminatorlib/optionparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ def parse_options():
optionslist[opt] = val and '%s'%val or ''
# optionslist = dbus.Dictionary(optionslist, signature='ss')
if util.DEBUG == True:
dbg('OptionParse::parse_options: command line options: %s' % options)
dbg('command line options: %s' % options)

return(options,optionslist)
6 changes: 3 additions & 3 deletions terminatorlib/paned.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def get_handlesize(self):

def wrapcloseterm(self, widget):
"""A child terminal has closed, so this container must die"""
dbg('Paned::wrapcloseterm: Called on %s' % widget)
dbg('Called on %s' % widget)

if self.closeterm(widget):
# At this point we only have one child, which is the surviving term
Expand Down Expand Up @@ -316,12 +316,12 @@ def wrapcloseterm(self, widget):
except AttributeError:
dbg('cannot find terminal with uuid: %s' % sibling.get_toplevel().last_active_term.urn)
else:
dbg("Paned::wrapcloseterm: self.closeterm failed")
dbg("self.closeterm failed")

def hoover(self):
"""Check that we still have a reason to exist"""
if len(self.children) == 1:
dbg('Paned::hoover: We only have one child, die')
dbg('We only have one child, die')
parent = self.get_parent()
child = self.children[0]
self.remove(child)
Expand Down
11 changes: 4 additions & 7 deletions terminatorlib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def prepare_attributes(self):
(head, _tail) = os.path.split(borg.__file__)
self.path.append(os.path.join(head, 'plugins'))
self.path.append(os.path.join(get_config_dir(), 'plugins'))
dbg('PluginRegistry::prepare_attributes: Plugin path: %s' %
self.path)
dbg('Plugin path: %s' % self.path)
if not self.done:
self.done = False
if not self.available_plugins:
Expand All @@ -73,7 +72,7 @@ def prepare_attributes(self):
def load_plugins(self):
"""Load all plugins present in the plugins/ directory in our module"""
if self.done:
dbg('PluginRegistry::load_plugins: Already loaded')
dbg('Already loaded')
return

config = Config()
Expand All @@ -90,8 +89,7 @@ def load_plugins(self):
continue
pluginpath = os.path.join(plugindir, plugin)
if os.path.isfile(pluginpath) and plugin[-3:] == '.py':
dbg('PluginRegistry::load_plugins: Importing plugin %s' %
plugin)
dbg('Importing plugin %s' % plugin)
try:
module = __import__(plugin[:-3], None, None, [''])
for item in getattr(module, 'AVAILABLE'):
Expand All @@ -113,7 +111,7 @@ def load_plugins(self):
def get_plugins_by_capability(self, capability):
"""Return a list of plugins with a particular capability"""
result = []
dbg('PluginRegistry::get_plugins_by_capability: searching %d plugins \
dbg('searching %d plugins \
for %s' % (len(self.instances), capability))
for plugin in self.instances:
if capability in self.instances[plugin].capabilities:
Expand Down Expand Up @@ -189,4 +187,3 @@ class MenuItem(Plugin):
def callback(self, menuitems, menu, terminal):
"""Callback to transform the enclosed URL"""
raise NotImplementedError

5 changes: 2 additions & 3 deletions terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def set_profile_values(self, profile):
self.config.set_profile(profile)
guiget = self.builder.get_object

dbg('PrefsEditor::set_profile_values: Setting profile %s' % profile)
dbg('Setting profile %s' % profile)

## General tab
# Use system font
Expand Down Expand Up @@ -1633,8 +1633,7 @@ def on_profile_name_edited(self, cell, path, newtext):
oldname = cell.get_property('text')
if oldname == newtext or oldname == 'default':
return
dbg('PrefsEditor::on_profile_name_edited: Changing %s to %s' %
(oldname, newtext))
dbg('Changing %s to %s' % (oldname, newtext))
self.config.rename_profile(oldname, newtext)
self.config.save()

Expand Down
14 changes: 7 additions & 7 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def populate_group_menu(self):
_('Broadcast _off'):'off'}.items()):
item = Gtk.RadioMenuItem.new_with_mnemonic(groupitems, key)
groupitems = item.get_group()
dbg('Terminal::populate_group_menu: %s active: %s' %
dbg('%s active: %s' %
(key, self.terminator.groupsend ==
self.terminator.groupsend_type[value]))
item.set_active(self.terminator.groupsend ==
Expand Down Expand Up @@ -618,7 +618,7 @@ def set_groupsend(self, _widget, value):
"""Set the groupsend mode"""
# FIXME: Can we think of a smarter way of doing this than poking?
if value in list(self.terminator.groupsend_type.values()):
dbg('Terminal::set_groupsend: setting groupsend to %s' % value)
dbg('setting groupsend to %s' % value)
self.terminator.groupsend = value

def do_splittogroup_toggle(self):
Expand Down Expand Up @@ -904,7 +904,7 @@ def on_group_button_press(self, widget, event):
def on_keypress(self, widget, event):
"""Handler for keyboard events"""
if not event:
dbg('Terminal::on_keypress: Called on %s with no event' % widget)
dbg('Called on %s with no event' % widget)
return False

# FIXME: Does keybindings really want to live in Terminator()?
Expand All @@ -915,7 +915,7 @@ def on_keypress(self, widget, event):

if mapping and mapping not in ['close_window',
'full_screen']:
dbg('Terminal::on_keypress: lookup found: %r' % mapping)
dbg('lookup found: %r' % mapping)
# handle the case where user has re-bound copy to ctrl+<key>
# we only copy if there is a selection otherwise let it fall through
# to ^<key>
Expand Down Expand Up @@ -1379,15 +1379,15 @@ def zoom_scale(self, widget, allocation, old_data):
new_rows = self.vte.get_row_count()
new_font = self.vte.get_font()

dbg('Terminal::zoom_scale: Resized from %dx%d to %dx%d' % (
dbg('Resized from %dx%d to %dx%d' % (
old_data['old_columns'],
old_data['old_rows'],
new_columns,
new_rows))

if new_rows == old_data['old_rows'] or \
new_columns == old_data['old_columns']:
dbg('Terminal::zoom_scale: One axis unchanged, not scaling')
dbg('One axis unchanged, not scaling')
return

scale_factor = min ( (new_columns / old_data['old_columns'] * 0.97),
Expand Down Expand Up @@ -1629,7 +1629,7 @@ def zoom_orig(self):
font = self.config.get_system_mono_font()
else:
font = self.config['font']
dbg("Terminal::zoom_orig: restoring font to: %s" % font)
dbg("restoring font to: %s" % font)
self.set_font(Pango.FontDescription(font))
self.custom_font_size = None

Expand Down
Loading

0 comments on commit fc528b2

Please sign in to comment.