Small non-impacting modifications

- 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
This commit is contained in:
mathieui 2012-07-26 00:09:23 +02:00
parent b7b7d6b3aa
commit 2767da0b78
3 changed files with 16 additions and 17 deletions

View file

@ -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')

View file

@ -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 <message type='error'><error/></message>
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], '')

View file

@ -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