From a35866ba8d0ea2959133331f41ddfad8ef74e23f Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Sun, 13 Jun 2010 16:01:38 +0000 Subject: code cleanup before 0.6 beta --- src/common.py | 3 +-- src/connection.py | 10 ---------- src/gui.py | 25 +++---------------------- src/message.py | 1 - src/multiuserchat.py | 8 +------- src/poezio.py | 10 ++++------ src/room.py | 2 -- src/user.py | 2 -- src/window.py | 17 ----------------- 9 files changed, 9 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/common.py b/src/common.py index 063ad424..9c7d31a3 100644 --- a/src/common.py +++ b/src/common.py @@ -33,7 +33,6 @@ """ various useful functions """ - import base64 import os import mimetypes @@ -60,8 +59,8 @@ def exception_handler(type_, value, trace): on any traceback: exit ncurses and print the traceback then exit the program """ - curses.echo() curses.endwin() + curses.echo() traceback.print_exception(type_, value, trace, None, sys.stderr) sys.exit(2) diff --git a/src/connection.py b/src/connection.py index 4abe2d5b..8ac8fc21 100644 --- a/src/connection.py +++ b/src/connection.py @@ -23,16 +23,6 @@ Defines the Connection class from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) -# from os.path import isfile - -# if isfile('../locale/poezio.pot'): -# localedir = '../locale' -# else: -# localedir = '/usr/share/locale' - -# bindtextdomain('poezio', localedir) -# textdomain('poezio') -# bind_textdomain_codeset('poezio', 'utf-8') import sys diff --git a/src/gui.py b/src/gui.py index fe200d23..133e38bb 100644 --- a/src/gui.py +++ b/src/gui.py @@ -23,18 +23,6 @@ from os.path import isfile from time import sleep -# if isfile('../locale/poezio.pot'): -# localedir = '../locale' -# else: -# localedir = '/usr/share/locale' - -# bindtextdomain('poezio', localedir) -# textdomain('poezio') -# bind_textdomain_codeset('poezio', 'utf-8') - -# import locale -# locale.setlocale(locale.LC_ALL, '') - import sys import curses @@ -51,9 +39,7 @@ from message import Message from connection import is_jid_the_same -from common import debug def doupdate(): - debug("doupdate") curses.doupdate() class Gui(object): @@ -64,8 +50,6 @@ class Gui(object): self.init_curses(stdscr) self.stdscr = stdscr self.window = Window(stdscr) - # self.window.new_room(self.current_room()) - # self.window.refresh(self.rooms) self.rooms = [Room('Info', '', self.window)] self.ignores = {} @@ -131,14 +115,11 @@ class Gui(object): main loop waiting for the user to press a key """ while 1: - # stdscr.leaveok(1) doupdate() try: key = stdscr.getkey() except: continue - from common import debug - # debug(str(key)) if str(key) in self.key_func.keys(): self.key_func[key]() elif str(key) == 'KEY_RESIZE': @@ -416,8 +397,6 @@ class Gui(object): # also change our nick in all private discussion of this room for _room in self.rooms: if _room.jid is not None and is_jid_the_same(_room.jid, room.name): - debug(_room.jid) - debug(room.name) _room.own_nick = stanza.getNick() user.change_nick(stanza.getNick()) self.add_message_to_room(room, _('%(old)s is now known as %(new)s') % {'old':from_nick, 'new':stanza.getNick()}) @@ -485,7 +464,6 @@ class Gui(object): # display the message in the room self.add_message_to_room(room, msg) private_room = self.get_room_by_name(stanza.getFrom()) - # debug('status change: ' + stanza.getFrom()+'\n') if private_room: # display the message in private self.add_message_to_room(private_room, msg) # finally, effectively change the user status @@ -788,6 +766,9 @@ class Gui(object): self.window.refresh(self.rooms) def command_query(self, args): + """ + /query + """ if len(args) != 1: return nick = args[0] diff --git a/src/message.py b/src/message.py index a95d12b0..8214e3d8 100644 --- a/src/message.py +++ b/src/message.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see . -from common import debug from datetime import datetime class Message(object): diff --git a/src/multiuserchat.py b/src/multiuserchat.py index be4d2277..b5e4a02e 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -23,8 +23,7 @@ import xmpp import common import threading -from time import (altzone, daylight, gmtime, localtime, mktime, strftime, - time as time_time, timezone, tzname) +from time import (altzone, gmtime, localtime, strftime, timezone) from handler import Handler from config import config @@ -99,8 +98,6 @@ class VcardSender(threading.Thread): iq3.addChild(k).setData(j[k]) else: iq2.addChild(i).setData(vcard[i]) - # id_ = self.connect.getAnId() - # iq.setID(id_) self.connection.send(iq) iq = xmpp.Iq(typ = 'set') iq2 = iq.setTag(xmpp.NS_VCARD_UPDATE) @@ -150,7 +147,6 @@ class MultiUserChat(object): self.connection.send(mes) def send_private_message(self, user_jid, message): - from common import debug mes = Message(to=user_jid) mes.setBody(message) mes.setType('chat') @@ -217,8 +213,6 @@ class MultiUserChat(object): code=code, msg=msg) - - def on_presence(self, presence): """Receive a MUC presence notification""" from_ = presence.getFrom().__str__() diff --git a/src/poezio.py b/src/poezio.py index dc714a4f..e2e6fd99 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -20,15 +20,13 @@ """ Starting point of poezio. Launches both the Connection and Gui """ - import sys -# import locale -# locale.setlocale(locale.LC_ALL, '') - # disable any printout (this would mess the display) -# sys.stdout = open('/dev/null', 'w') -sys.stderr = open('errors', 'w') +if len(sys.argv) == 2: + sys.stderr = open('errors', 'a') +else: + sys.stderr = open('/dev/null', 'a') from connection import Connection from multiuserchat import MultiUserChat diff --git a/src/room.py b/src/room.py index bea68d05..f9dcabfc 100644 --- a/src/room.py +++ b/src/room.py @@ -46,8 +46,6 @@ class Room(object): if len(self.messages) <= y: return self.pos += 14 - from common import debug - debug(str(y_x)) if self.pos + y >= len(self.messages): self.pos = len(self.messages) - y+3 diff --git a/src/user.py b/src/user.py index 6f0f3328..8ec76ba4 100644 --- a/src/user.py +++ b/src/user.py @@ -51,11 +51,9 @@ class User(object): get a int Return True if the user talked since the last s seconds """ - from common import debug if self.last_talked is None: return False delta = timedelta(0, t) - debug("Last talk: %s\nDelai:%s\nDelta:%s\n" % (str(self.last_talked), str(t), str(delta))) if datetime.now() - delta > self.last_talked: return False return True diff --git a/src/window.py b/src/window.py index 8532e541..19fcc63b 100644 --- a/src/window.py +++ b/src/window.py @@ -22,23 +22,12 @@ from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) from os.path import isfile -# if isfile('../locale/poezio.pot'): -# localedir = '../locale' -# else: -# localedir = '/usr/share/locale' - -# bindtextdomain('poezio', localedir) -# textdomain('poezio') -# bind_textdomain_codeset('poezio', 'utf-8') - import locale locale.setlocale(locale.LC_ALL, '') import curses from config import config -from common import debug - from message import Line class Win(object): @@ -60,7 +49,6 @@ class Win(object): pass self.win.idlok(1) self.win.leaveok(1) - # self.win.syncok(0) def refresh(self): self.win.noutrefresh() @@ -238,7 +226,6 @@ class TextWin(Win): Build the Line objects from the messages, and then write them in the text area """ - from common import debug if not self.visible: return self.win.erase() @@ -605,7 +592,6 @@ class Window(object): 'room' is the current one """ room = rooms[0] # get current room - # self.text_win.redraw(room) self.text_win.refresh(room) self.user_win.refresh(room.users) self.topic_win.refresh(room.topic, room.jid) @@ -615,6 +601,3 @@ class Window(object): def do_command(self, key): self.input.do_command(key) self.input.refresh() - - # def new_room(self, room): - # self.text_win.new_win(room.name) -- cgit v1.2.3