From 2767da0b78512f9070506ead32bd3fe4a16b2450 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 26 Jul 2012 00:09:23 +0200 Subject: Small non-impacting modifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Write the config with “option = value” instead of “option= value” - Docstring for sighup_handler - Optimize a join() in the main loop - Rename the verbose get_error_message_from_error_stanza() with get_error_message() - Remove the unused Tab.just_before_refresh() which is litterally used nowhere in poezio --- src/config.py | 8 ++++---- src/core.py | 17 ++++++++++++----- src/tabs.py | 8 -------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/config.py b/src/config.py index 6695c074..742bd947 100644 --- a/src/config.py +++ b/src/config.py @@ -127,7 +127,7 @@ class Config(RawConfigParser): for line in lines_before: if line.startswith('['): # check the section if we_are_in_the_right_section and not written: - result_lines.append('%s= %s' % (option, value)) + result_lines.append('%s = %s' % (option, value)) written = True if line == '[%s]' % section: we_are_in_the_right_section = True @@ -137,15 +137,15 @@ class Config(RawConfigParser): if (line.startswith('%s ' % (option,)) or line.startswith('%s=' % (option,)) or line.startswith('%s = ' % (option,))) and we_are_in_the_right_section: - line = '%s= %s' % (option, value) + line = '%s = %s' % (option, value) written = True result_lines.append(line) if not section_found: result_lines.append('[%s]' % section) - result_lines.append('%s= %s' % (option, value)) + result_lines.append('%s = %s' % (option, value)) elif not written: - result_lines.append('%s= %s' % (option, value)) + result_lines.append('%s = %s' % (option, value)) df = open(self.file_name, 'w') diff --git a/src/core.py b/src/core.py index f4d11a38..9159bfe0 100644 --- a/src/core.py +++ b/src/core.py @@ -286,6 +286,10 @@ class Core(object): self.pending_invites = {} def sighup_handler(self, num, stack): + """ + Handle SIGHUP (1) + When caught, reload all the possible files. + """ log.debug("SIGHUP caught, reloading the files…") # reload all log files log.debug("Reloading the log files…") @@ -1139,7 +1143,10 @@ class Core(object): if res: self.refresh_window() else: - self.do_command(''.join(list(map(replace_line_breaks, list(map(replace_tabulation, char_list))))), True) + self.do_command(''.join(map( + lambda x: replace_line_breaks(replace_tabulation(x)), + char_list) + ), True) self.refresh_window() self.doupdate() @@ -1303,7 +1310,7 @@ class Core(object): self.current_tab().on_half_scroll_down() self.refresh_window() - def get_error_message_from_error_stanza(self, stanza, deprecated=False): + def get_error_message(self, stanza, deprecated=False): """ Takes a stanza of the form and return a well formed string containing the error informations @@ -1335,7 +1342,7 @@ class Core(object): Display the error in the tab """ tab = self.get_tab_by_name(room_name) - error_message = self.get_error_message_from_error_stanza(error) + error_message = self.get_error_message(error) self.add_message_to_text_buffer(tab._text_buffer, error_message) code = error['error']['code'] if code == '401': @@ -1829,7 +1836,7 @@ class Core(object): else: return True items = ['%s/%s' % (tup[0], jid.resource) for tup in items] - for i in range(len(jid.server) + 2 + len(jid.resource)): + for _ in range(len(jid.server) + 2 + len(jid.resource)): the_input.key_backspace() else: items = [] @@ -2166,7 +2173,7 @@ class Core(object): else: self.information('No bookmark to remove', 'Info') - def completion_remove_bookmark(self,the_input): + def completion_remove_bookmark(self, the_input): """Completion for /remove_bookmark""" return the_input.auto_completion([bm.jid for bm in bookmark.bookmarks], '') diff --git a/src/tabs.py b/src/tabs.py index f697d888..7eed1790 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -352,14 +352,6 @@ class Tab(object): """ pass - def just_before_refresh(self): - """ - Method called just before the screen refresh. - Particularly useful to move the cursor at the - correct position. - """ - pass - def on_close(self): """ Called when the tab is to be closed -- cgit v1.2.3