summaryrefslogtreecommitdiff
path: root/src/core/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-31 19:15:57 +0100
committermathieui <mathieui@mathieui.net>2014-10-31 19:16:44 +0100
commit1c1ab3cb839e5509db52770e10c7190f844eb2e5 (patch)
treeb331060b3dc42651e61e4ccb2dfe6af5e2e97752 /src/core/core.py
parentcedc5a6ec80a46437f42464415fd1806049c593d (diff)
parentea2b703bfd07d293ba9fdd85ac657275d43da2a7 (diff)
downloadpoezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.gz
poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.bz2
poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.tar.xz
poezio-1c1ab3cb839e5509db52770e10c7190f844eb2e5.zip
Merge branch 'master' of git.poez.io:poezio into slix
Conflicts: src/bookmark.py src/config.py src/connection.py src/core/commands.py src/core/core.py src/core/handlers.py src/windows/info_bar.py src/windows/muc.py src/windows/roster_win.py src/windows/text_win.py src/xhtml.py
Diffstat (limited to 'src/core/core.py')
-rw-r--r--src/core/core.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/core/core.py b/src/core/core.py
index eeb25c83..70136250 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -65,10 +65,10 @@ class Core(object):
sys.excepthook = self.on_exception
self.connection_time = time.time()
self.stdscr = None
- status = config.get('status', None)
+ status = config.get('status')
status = possible_show.get(status, None)
self.status = Status(show=status,
- message=config.get('status_message', ''))
+ message=config.get('status_message'))
self.running = True
self.xmpp = singleton.Singleton(connection.Connection)
self.xmpp.core = self
@@ -83,7 +83,7 @@ class Core(object):
# that are displayed in almost all tabs, in an
# information window.
self.information_buffer = TextBuffer()
- self.information_win_size = config.get('info_win_height', 2, 'var')
+ self.information_win_size = config.get('info_win_height', section='var')
self.information_win = windows.TextWin(300)
self.information_buffer.add_window(self.information_win)
self.left_tab_win = None
@@ -97,7 +97,7 @@ class Core(object):
self._current_tab_nb = 0
self.previous_tab_nb = 0
- own_nick = config.get('default_nick', '')
+ own_nick = config.get('default_nick')
own_nick = own_nick or self.xmpp.boundjid.user
own_nick = own_nick or os.environ.get('USER')
own_nick = own_nick or 'poezio'
@@ -127,7 +127,7 @@ class Core(object):
self.register_initial_commands()
# We are invisible
- if not config.get('send_initial_presence', True):
+ if not config.get('send_initial_presence'):
del self.commands['status']
del self.commands['show']
@@ -256,19 +256,19 @@ class Core(object):
connection.MatchAll(None),
self.incoming_stanza)
self.xmpp.register_handler(self.all_stanzas)
- if config.get('enable_user_tune', True):
+ if config.get('enable_user_tune'):
self.xmpp.add_event_handler("user_tune_publish",
self.on_tune_event)
- if config.get('enable_user_nick', True):
+ if config.get('enable_user_nick'):
self.xmpp.add_event_handler("user_nick_publish",
self.on_nick_received)
- if config.get('enable_user_mood', True):
+ if config.get('enable_user_mood'):
self.xmpp.add_event_handler("user_mood_publish",
self.on_mood_event)
- if config.get('enable_user_activity', True):
+ if config.get('enable_user_activity'):
self.xmpp.add_event_handler("user_activity_publish",
self.on_activity_event)
- if config.get('enable_user_gaming', True):
+ if config.get('enable_user_gaming'):
self.xmpp.add_event_handler("user_gaming_publish",
self.on_gaming_event)
@@ -357,13 +357,14 @@ class Core(object):
"""
Called when the request_message_receipts option changes
"""
- self.xmpp.plugin['xep_0184'].auto_request = config.get(option, True)
+ self.xmpp.plugin['xep_0184'].auto_request = config.get(option,
+ default=True)
def on_ack_receipts_config_change(self, option, value):
"""
Called when the ack_message_receipts option changes
"""
- self.xmpp.plugin['xep_0184'].auto_ack = config.get(option, True)
+ self.xmpp.plugin['xep_0184'].auto_ack = config.get(option, default=True)
def on_plugins_dir_config_change(self, option, value):
"""
@@ -419,7 +420,7 @@ class Core(object):
old_section = old_config.get(section, {})
for option in config.options(section):
old_value = old_section.get(option)
- new_value = config.get(option, "", section)
+ new_value = config.get(option, default="", section=section)
if new_value != old_value:
self.trigger_configuration_change(option, new_value)
log.debug("Config reloaded.")
@@ -441,11 +442,11 @@ class Core(object):
}
log.error("%s received. Exiting…", signals[sig])
- if config.get('enable_user_mood', True):
+ if config.get('enable_user_mood'):
self.xmpp.plugin['xep_0107'].stop()
- if config.get('enable_user_activity', True):
+ if config.get('enable_user_activity'):
self.xmpp.plugin['xep_0108'].stop()
- if config.get('enable_user_gaming', True):
+ if config.get('enable_user_gaming'):
self.xmpp.plugin['xep_0196'].stop()
self.plugin_manager.disable_plugins()
self.disconnect('%s received' % signals.get(sig))
@@ -455,7 +456,7 @@ class Core(object):
"""
Load the plugins on startup.
"""
- plugins = config.get('plugins_autoload', '')
+ plugins = config.get('plugins_autoload')
if ':' in plugins:
for plugin in plugins.split(':'):
self.plugin_manager.load(plugin)
@@ -704,9 +705,9 @@ class Core(object):
work. If you try to do anything else, your |, [, <<, etc will be
interpreted as normal command arguments, not shell special tokens.
"""
- if config.get('exec_remote', False):
+ if config.get('exec_remote'):
# We just write the command in the fifo
- fifo_path = config.get('remote_fifo_path', './')
+ fifo_path = config.get('remote_fifo_path')
if not self.remote_fifo:
try:
self.remote_fifo = Fifo(os.path.join(fifo_path,
@@ -802,7 +803,7 @@ class Core(object):
or to use it when joining a new muc)
"""
self.status = Status(show=pres, message=msg)
- if config.get('save_status', True):
+ if config.get('save_status'):
ok = config.silent_set('status', pres if pres else '')
msg = msg.replace('\n', '|') if msg else ''
ok = ok and config.silent_set('status_message', msg)
@@ -1043,7 +1044,7 @@ class Core(object):
return False
elif not self.tabs[old_pos]:
return False
- if config.get('create_gaps', False):
+ if config.get('create_gaps'):
return self.insert_tab_gaps(old_pos, new_pos)
return self.insert_tab_nogaps(old_pos, new_pos)
@@ -1294,7 +1295,7 @@ class Core(object):
if self.previous_tab_nb != nb:
self.current_tab_nb = self.previous_tab_nb
self.previous_tab_nb = 0
- if config.get('create_gaps', False):
+ if config.get('create_gaps'):
if nb >= len(self.tabs) - 1:
self.tabs.remove(tab)
nb -= 1
@@ -1345,7 +1346,7 @@ class Core(object):
"""
Displays an informational message in the "Info" buffer
"""
- filter_messages = config.get('filter_info_messages', '').split(':')
+ filter_messages = config.get('filter_info_messages').split(':')
for words in filter_messages:
if words and words in msg:
log.debug('Did not show the message:\n\t%s> %s', typ, msg)
@@ -1355,12 +1356,11 @@ class Core(object):
nb_lines = self.information_buffer.add_message(msg,
nickname=typ,
nick_color=color)
- popup_on = config.get('information_buffer_popup_on',
- 'error roster warning help info').split()
+ popup_on = config.get('information_buffer_popup_on').split()
if isinstance(self.current_tab(), tabs.RosterInfoTab):
self.refresh_window()
elif typ != '' and typ.lower() in popup_on:
- popup_time = config.get('popup_time', 4) + (nb_lines - 1) * 2
+ popup_time = config.get('popup_time') + (nb_lines - 1) * 2
self.pop_information_win_up(nb_lines, popup_time)
else:
if self.information_win_size != 0:
@@ -1553,7 +1553,7 @@ class Core(object):
"""
Enable/disable the left panel.
"""
- enabled = config.get('enable_vertical_tab_list', False)
+ enabled = config.get('enable_vertical_tab_list')
if not config.silent_set('enable_vertical_tab_list', str(not enabled)):
self.information(_('Unable to write in the config file'), 'Error')
self.call_for_resize()
@@ -1578,14 +1578,14 @@ class Core(object):
Resize the GlobalInfoBar only once at each resize
"""
height, width = self.stdscr.getmaxyx()
- if config.get('enable_vertical_tab_list', False):
+ if config.get('enable_vertical_tab_list'):
if self.size.core_degrade_x:
return
try:
height, _ = self.stdscr.getmaxyx()
truncated_win = self.stdscr.subwin(height,
- config.get('vertical_tab_list_size', 20),
+ config.get('vertical_tab_list_size'),
0, 0)
except:
log.error('Curses error on infobar resize', exc_info=True)
@@ -1623,11 +1623,11 @@ class Core(object):
# the screen that they can occupy, and we draw the tab list on the
# remaining space, on the left
height, width = self.stdscr.getmaxyx()
- if (config.get('enable_vertical_tab_list', False) and
+ if (config.get('enable_vertical_tab_list') and
not self.size.core_degrade_x):
try:
scr = self.stdscr.subwin(0,
- config.get('vertical_tab_list_size', 20))
+ config.get('vertical_tab_list_size'))
except:
log.error('Curses error on resize', exc_info=True)
return
@@ -1637,7 +1637,7 @@ class Core(object):
self.resize_global_info_bar()
self.resize_global_information_win()
for tab in self.tabs:
- if config.get('lazy_resize', True):
+ if config.get('lazy_resize'):
tab.need_resize = True
else:
tab.resize()
@@ -1865,7 +1865,7 @@ class Core(object):
usage='<jid>',
shortdesc=_('List available ad-hoc commands on the given jid'))
- if config.get('enable_user_activity', True):
+ if config.get('enable_user_activity'):
self.register_command('activity', self.command_activity,
usage='[<general> [specific] [text]]',
desc=_('Send your current activity to your contacts '
@@ -1873,7 +1873,7 @@ class Core(object):
'"stop broadcasting an activity".'),
shortdesc=_('Send your activity.'),
completion=self.completion_activity)
- if config.get('enable_user_mood', True):
+ if config.get('enable_user_mood'):
self.register_command('mood', self.command_mood,
usage='[<mood> [text]]',
desc=_('Send your current mood to your contacts '
@@ -1881,7 +1881,7 @@ class Core(object):
'"stop broadcasting a mood".'),
shortdesc=_('Send your mood.'),
completion=self.completion_mood)
- if config.get('enable_user_gaming', True):
+ if config.get('enable_user_gaming'):
self.register_command('gaming', self.command_gaming,
usage='[<game name> [server address]]',
desc=_('Send your current gaming activity to '
@@ -2025,7 +2025,7 @@ def replace_key_with_bound(key):
Replace an inputted key with the one defined as its replacement
in the config
"""
- bind = config.get(key, key, 'bindings')
+ bind = config.get(key, default=key, section='bindings')
if not bind:
bind = key
return bind