diff options
Diffstat (limited to 'src')
36 files changed, 262 insertions, 261 deletions
diff --git a/src/advanced.py b/src/advanced.py index 91a706bbc..8c33aef44 100644 --- a/src/advanced.py +++ b/src/advanced.py @@ -102,24 +102,24 @@ class AdvancedConfigurationWindow(object): self.restart_label.hide() gajim.interface.instances['advanced_config'] = self - def cb_value_column_data(self, col, cell, model, iter): + def cb_value_column_data(self, col, cell, model, iter_): '''check if it's boolen or holds password stuff and if yes make the cellrenderertext not editable else it's editable''' - optname = model[iter][C_PREFNAME] - opttype = model[iter][C_TYPE] + optname = model[iter_][C_PREFNAME] + opttype = model[iter_][C_TYPE] if opttype == self.types['boolean'] or optname == 'password': cell.set_property('editable', False) else: cell.set_property('editable', True) - def get_option_path(self, model, iter): + def get_option_path(self, model, iter_): # It looks like path made from reversed array # path[0] is the true one optname # path[1] is the key name # path[2] is the root of tree # last two is optional - path = [model[iter][0].decode('utf-8')] - parent = model.iter_parent(iter) + path = [model[iter_][0].decode('utf-8')] + parent = model.iter_parent(iter_) while parent: path.append(model[parent][0].decode('utf-8')) parent = model.iter_parent(parent) @@ -249,14 +249,14 @@ class AdvancedConfigurationWindow(object): value = self.right_true_dict[value] model.append(iter, [name, value, type]) - def visible_func(self, model, iter): + def visible_func(self, model, iter_): str = self.entry.get_text().decode('utf-8') if str in (None, ''): return True # show all - name = model[iter][C_PREFNAME].decode('utf-8') + name = model[iter_][C_PREFNAME].decode('utf-8') # If a child of the iter matches, we return True - if model.iter_has_child(iter): - iterC = model.iter_children(iter) + if model.iter_has_child(iter_): + iterC = model.iter_children(iter_) while iterC: nameC = model[iterC][C_PREFNAME].decode('utf-8') if model.iter_has_child(iterC): diff --git a/src/cell_renderer_image.py b/src/cell_renderer_image.py index 2693030d5..2cdbaca18 100644 --- a/src/cell_renderer_image.py +++ b/src/cell_renderer_image.py @@ -45,9 +45,9 @@ class CellRendererImage(gtk.GenericCellRenderer): def do_get_property(self, pspec): return getattr(self, pspec.name) - def func(self, model, path, iter, image_tree): + def func(self, model, path, iter_, image_tree): image, tree = image_tree - if model.get_value(iter, self.tv_index) != image: + if model.get_value(iter_, self.tv_index) != image: return self.redraw = 1 col = tree.get_column(self.col_index) diff --git a/src/chat_control.py b/src/chat_control.py index 323dd6ea1..0065b06a1 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -593,7 +593,7 @@ class ChatControlBase(MessageControl): return True return False - def send_message(self, message, keyID = '', type = 'chat', chatstate = None, + def send_message(self, message, keyID = '', type_ = 'chat', chatstate = None, msg_id = None, composing_xep = None, resource = None, process_command = True): '''Send the given message to the active tab. Doesn't return None if error @@ -604,7 +604,7 @@ class ChatControlBase(MessageControl): ret = None if not process_command or not self._process_command(message): - ret = MessageControl.send_message(self, message, keyID, type = type, + ret = MessageControl.send_message(self, message, keyID, type_ = type_, chatstate = chatstate, msg_id = msg_id, composing_xep = composing_xep, resource = resource, user_nick = self.user_nick) @@ -1720,7 +1720,7 @@ class ChatControl(ChatControlBase): self._schedule_activity_timers() id = ChatControlBase.send_message(self, message, keyID, - type = 'chat', chatstate = chatstate_to_send, + type_ = 'chat', chatstate = chatstate_to_send, composing_xep = composing_xep, process_command = process_command) if id: diff --git a/src/common/GnuPG.py b/src/common/GnuPG.py index ca78a9cac..ab88c200a 100644 --- a/src/common/GnuPG.py +++ b/src/common/GnuPG.py @@ -68,12 +68,12 @@ if gajim.HAVE_GPG: resp[ keyword ] = "" return resp - def encrypt(self, str, recipients): + def encrypt(self, str_, recipients): self.options.recipients = recipients # a list! proc = self.run(['--encrypt'], create_fhs=['stdin', 'stdout', 'status', 'stderr']) - proc.handles['stdin'].write(str) + proc.handles['stdin'].write(str_) try: proc.handles['stdin'].close() except IOError: @@ -103,9 +103,9 @@ if gajim.HAVE_GPG: error = '' return self._stripHeaderFooter(output), error - def decrypt(self, str, keyID): + def decrypt(self, str_, keyID): proc = self.run(['--decrypt', '-q', '-u %s'%keyID], create_fhs=['stdin', 'stdout']) - enc = self._addHeaderFooter(str, 'MESSAGE') + enc = self._addHeaderFooter(str_, 'MESSAGE') proc.handles['stdin'].write(enc) proc.handles['stdin'].close() @@ -116,9 +116,9 @@ if gajim.HAVE_GPG: except IOError: pass return output - def sign(self, str, keyID): + def sign(self, str_, keyID): proc = self.run(['-b', '-u %s'%keyID], create_fhs=['stdin', 'stdout', 'status', 'stderr']) - proc.handles['stdin'].write(str) + proc.handles['stdin'].write(str_) try: proc.handles['stdin'].close() except IOError: @@ -144,12 +144,12 @@ if gajim.HAVE_GPG: return self._stripHeaderFooter(output) return 'BAD_PASSPHRASE' - def verify(self, str, sign): - if str is None: + def verify(self, str_, sign): + if str_ is None: return '' f = tmpfile() fd = f.fileno() - f.write(str) + f.write(str_) f.seek(0) proc = self.run(['--verify', '--enable-special-filenames', '-', '-&%s'%fd], create_fhs=['stdin', 'status', 'stderr']) @@ -215,13 +215,13 @@ if gajim.HAVE_GPG: line = '\n'.join(lines[0:i]) return line - def _addHeaderFooter(self, data, type): + def _addHeaderFooter(self, data, type_): """Add header and footer from data""" - out = "-----BEGIN PGP %s-----\n" % type + out = "-----BEGIN PGP %s-----\n" % type_ out = out + "Version: PGP\n" out = out + "\n" out = out + data + "\n" - out = out + "-----END PGP %s-----\n" % type + out = out + "-----END PGP %s-----\n" % type_ return out # vim: se ts=3: diff --git a/src/common/caps.py b/src/common/caps.py index bae1e1d34..95598449c 100644 --- a/src/common/caps.py +++ b/src/common/caps.py @@ -89,10 +89,10 @@ class CapsCache(object): # TODO: maybe put all known xmpp namespace strings here # (strings given in xmpppy)? __names = {} - def __init__(ciself, hash_method, hash): + def __init__(ciself, hash_method, hash_): # cached into db ciself.hash_method = hash_method - ciself.hash = hash + ciself.hash = hash_ ciself._features = [] ciself._identities = [] @@ -174,14 +174,14 @@ class CapsCache(object): self.__cache[(hash_method, hash)] = x return x - def preload(self, con, jid, node, hash_method, hash): + def preload(self, con, jid, node, hash_method, hash_): ''' Preload data about (node, ver, exts) caps using disco query to jid using proper connection. Don't query if the data is already in cache. ''' if hash_method == 'old': - q = self[(hash_method, node + '#' + hash)] + q = self[(hash_method, node + '#' + hash_)] else: - q = self[(hash_method, hash)] + q = self[(hash_method, hash_)] if q.queried==0: # do query for bare node+hash pair @@ -190,7 +190,7 @@ class CapsCache(object): if hash_method == 'old': con.discoverInfo(jid) else: - con.discoverInfo(jid, '%s#%s' % (node, hash)) + con.discoverInfo(jid, '%s#%s' % (node, hash_)) def is_supported(self, contact, feature): if not contact: diff --git a/src/common/commands.py b/src/common/commands.py index 1d238aa0c..1c012290d 100644 --- a/src/common/commands.py +++ b/src/common/commands.py @@ -271,7 +271,7 @@ class ForwardMessagesCommand(AdHocCommand): for jid in events: for event in events[jid]: self.connection.send_message(j, event.parameters[0], '', - type=event.type_, subject=event.parameters[1], + type_=event.type_, subject=event.parameters[1], resource=resource, forward_from=jid, delayed=event.time_) # Inform other client of completion diff --git a/src/common/config.py b/src/common/config.py index 828168059..5d284980d 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -502,17 +502,17 @@ class Config: def is_valid_string(self, val): return val - def is_valid(self, type, val): - if not type: + def is_valid(self, type_, val): + if not type_: return None - if type[0] == 'boolean': + if type_[0] == 'boolean': return self.is_valid_bool(val) - elif type[0] == 'integer': + elif type_[0] == 'integer': return self.is_valid_int(val) - elif type[0] == 'string': + elif type_[0] == 'string': return self.is_valid_string(val) else: - if re.match(type[1], val): + if re.match(type_[1], val): return val else: return None diff --git a/src/common/connection.py b/src/common/connection.py index 49454f9ae..84c48f9ac 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1071,7 +1071,7 @@ class Connection(ConnectionHandlers): self.connection.send(msg_iq) - def send_message(self, jid, msg, keyID, type='chat', subject='', + def send_message(self, jid, msg, keyID, type_='chat', subject='', chatstate=None, msg_id=None, composing_xep=None, resource=None, user_nick=None, xhtml=None, session=None, forward_from=None, form_node=None, original_message=None, delayed=None): @@ -1114,8 +1114,8 @@ class Connection(ConnectionHandlers): 'rst_formatting_outgoing_messages'): # Generate a XHTML part using reStructured text markup xhtml = create_xhtml(msgtxt) - if type == 'chat': - msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type, + if type_ == 'chat': + msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type_, xhtml = xhtml) else: if subject: @@ -1210,7 +1210,7 @@ class Connection(ConnectionHandlers): log_msg = _('Subject: %(subject)s\n%(message)s') % \ {'subject': subject, 'message': msg} if log_msg: - if type == 'chat': + if type_ == 'chat': kind = 'chat_msg_sent' else: kind = 'single_msg_sent' diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index bca5bb557..86004fa7b 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1280,7 +1280,7 @@ class ConnectionHandlersBase: return session if pm: - return self.make_new_session(fjid, thread_id, type='pm') + return self.make_new_session(fjid, thread_id, type_='pm') else: return self.make_new_session(fjid, thread_id) @@ -1349,15 +1349,15 @@ sent a message to.''' except (KeyError, IndexError): return None - def make_new_session(self, jid, thread_id=None, type='chat', cls=None): + def make_new_session(self, jid, thread_id=None, type_='chat', cls=None): if not cls: cls = gajim.default_session_type - sess = cls(self, common.xmpp.JID(jid), thread_id, type) + sess = cls(self, common.xmpp.JID(jid), thread_id, type_) # determine if this session is a pm session # if not, discard the resource so that all sessions are stored bare - if not type == 'pm': + if not type_ == 'pm': jid = gajim.get_jid_without_resource(jid) if not jid in self.sessions: diff --git a/src/common/crypto.py b/src/common/crypto.py index 2044cd9af..b9d90151e 100644 --- a/src/common/crypto.py +++ b/src/common/crypto.py @@ -75,8 +75,8 @@ def base28(n): else: return base28_chr[n] -def random_bytes(bytes): - return os.urandom(bytes) +def random_bytes(bytes_): + return os.urandom(bytes_) def generate_nonce(): return random_bytes(8) diff --git a/src/common/dataforms.py b/src/common/dataforms.py index 144df2bab..2d5c3fb86 100644 --- a/src/common/dataforms.py +++ b/src/common/dataforms.py @@ -351,12 +351,12 @@ class DataRecord(ExtendedNode): return self.vars[item] class DataForm(ExtendedNode): - def __init__(self, type=None, title=None, instructions=None, extend=None): + def __init__(self, type_=None, title=None, instructions=None, extend=None): if extend is None: # we have to build form from scratch xmpp.Node.__init__(self, 'x', attrs={'xmlns': xmpp.NS_DATA}) - if type is not None: self.type=type + if type_ is not None: self.type_=type_ if title is not None: self.title=title if instructions is not None: self.instructions=instructions @@ -367,9 +367,9 @@ class DataForm(ExtendedNode): filledform = DataForm(replyto=thisform)...''' def fget(self): return self.getAttr('type') - def fset(self, type): - assert type in ('form', 'submit', 'cancel', 'result') - self.setAttr('type', type) + def fset(self, type_): + assert type_ in ('form', 'submit', 'cancel', 'result') + self.setAttr('type', type_) return locals() @nested_property @@ -406,8 +406,8 @@ class DataForm(ExtendedNode): return locals() class SimpleDataForm(DataForm, DataRecord): - def __init__(self, type=None, title=None, instructions=None, fields=None, extend=None): - DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend) + def __init__(self, type_=None, title=None, instructions=None, fields=None, extend=None): + DataForm.__init__(self, type_=type_, title=title, instructions=instructions, extend=extend) DataRecord.__init__(self, fields=fields, extend=self, associated=self) def get_purged(self): @@ -430,8 +430,8 @@ class SimpleDataForm(DataForm, DataRecord): return c class MultipleDataForm(DataForm): - def __init__(self, type=None, title=None, instructions=None, items=None, extend=None): - DataForm.__init__(self, type=type, title=title, instructions=instructions, extend=extend) + def __init__(self, type_=None, title=None, instructions=None, items=None, extend=None): + DataForm.__init__(self, type_=type_, title=title, instructions=instructions, extend=extend) # all records, recorded into DataRecords if extend is None: diff --git a/src/common/helpers.py b/src/common/helpers.py index cfcaf06ba..1c76faf0d 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -852,7 +852,7 @@ def sanitize_filename(filename): return filename -def allow_showing_notification(account, type = 'notify_on_new_message', +def allow_showing_notification(account, type_ = 'notify_on_new_message', advanced_notif_num = None, is_first_message = True): '''is it allowed to show nofication? check OUR status and if we allow notifications for that status @@ -865,7 +865,7 @@ advanced_notif_num = None, is_first_message = True): return True if popup == 'no': return False - if type and (not gajim.config.get(type) or not is_first_message): + if type_ and (not gajim.config.get(type_) or not is_first_message): return False if gajim.config.get('autopopupaway'): # always show notification return True diff --git a/src/common/logger.py b/src/common/logger.py index c9e610f2d..c7f79b396 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -749,7 +749,7 @@ class Logger: sql = 'DELETE FROM caps_cache WHERE hash_method = "%s" AND hash = "%s"' % (hash_method, hash) self.simple_commit(sql) - def add_caps_entry(self, hash_method, hash, identities, features): + def add_caps_entry(self, hash_method, hash_, identities, features): data=[] for identity in identities: # there is no FEAT category @@ -770,7 +770,7 @@ class Logger: self.cur.execute(''' INSERT INTO caps_cache ( hash_method, hash, data ) VALUES (?, ?, ?); - ''', (hash_method, hash, buffer(data))) # (1) -- note above + ''', (hash_method, hash_, buffer(data))) # (1) -- note above try: self.con.commit() except sqlite.OperationalError, e: diff --git a/src/common/nslookup.py b/src/common/nslookup.py index 9640d1dd8..e6dec5c76 100644 --- a/src/common/nslookup.py +++ b/src/common/nslookup.py @@ -280,11 +280,11 @@ class IdleCommand(IdleObject): self._return_result() class NsLookup(IdleCommand): - def __init__(self, on_result, host='_xmpp-client', type = 'srv'): + def __init__(self, on_result, host='_xmpp-client', type_ = 'srv'): IdleCommand.__init__(self, on_result) self.commandtimeout = 10 self.host = host.lower() - self.type = type.lower() + self.type = type_.lower() if not host_pattern.match(self.host): # invalid host name print >> sys.stderr, 'Invalid host: %s' % self.host diff --git a/src/common/pubsub.py b/src/common/pubsub.py index deb35469f..b8477b427 100644 --- a/src/common/pubsub.py +++ b/src/common/pubsub.py @@ -58,21 +58,21 @@ class ConnectionPubSub: self.__callbacks[id]=(cb, args, kwargs) - def send_pb_publish(self, jid, node, item, id): + def send_pb_publish(self, jid, node, item, id_): '''Publish item to a node.''' query = xmpp.Iq('set', to=jid) e = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) e = e.addChild('publish', {'node': node}) - e = e.addChild('item', {'id': id}, [item]) # TODO: we should generate id... or we shouldn't? + e = e.addChild('item', {'id': id_}, [item]) # TODO: we should generate id... or we shouldn't? self.connection.send(query) - def send_pb_retract(self, jid, node, id): + def send_pb_retract(self, jid, node, id_): '''Delete item from a node''' query = xmpp.Iq('set', to=jid) r = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB) r = r.addChild('retract', {'node': node, 'notify': '1'}) - r = r.addChild('item', {'id': id}) + r = r.addChild('item', {'id': id_}) self.connection.send(query) diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index d334ac1e5..cb1d7fb7f 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -41,19 +41,19 @@ import os XmlDsig = 'http://www.w3.org/2000/09/xmldsig#' class StanzaSession(object): - def __init__(self, conn, jid, thread_id, type): + def __init__(self, conn, jid, thread_id, type_): self.conn = conn self.jid = jid - self.type = type + self.type = type_ if thread_id: self.received_thread_id = True self.thread_id = thread_id else: self.received_thread_id = False - if type == 'normal': + if type_ == 'normal': self.thread_id = None else: self.thread_id = self.generate_thread_id() @@ -189,8 +189,8 @@ if gajim.HAVE_PYCRYPTO: # handle_session_negotiation method. class EncryptedStanzaSession(StanzaSession): - def __init__(self, conn, jid, thread_id, type='chat'): - StanzaSession.__init__(self, conn, jid, thread_id, type='chat') + def __init__(self, conn, jid, thread_id, type_='chat'): + StanzaSession.__init__(self, conn, jid, thread_id, type_='chat') self.xes = {} self.es = {} diff --git a/src/common/xmpp/browser.py b/src/common/xmpp/browser.py index 65fed4280..a23b6404f 100644 --- a/src/common/xmpp/browser.py +++ b/src/common/xmpp/browser.py @@ -96,7 +96,7 @@ class Browser(PlugIn): self._owner.UnregisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_INFO) self._owner.UnregisterHandler('iq',self._DiscoveryHandler,typ='get',ns=NS_DISCO_ITEMS) - def _traversePath(self,node,jid,set=0): + def _traversePath(self,node,jid,set_=0): """ Returns dictionary and key or None,None None - root node (w/o "node" attribute) /a/b/c - node @@ -105,7 +105,7 @@ class Browser(PlugIn): get returns '' or None as the key or None as the dict. Used internally.""" if jid in self._handlers: cur=self._handlers[jid] - elif set: + elif set_: self._handlers[jid]={} cur=self._handlers[jid] else: cur=self._handlers[''] @@ -113,10 +113,10 @@ class Browser(PlugIn): else: node=node.replace('/',' /').split('/') for i in node: if i!='' and i in cur: cur=cur[i] - elif set and i!='': cur[i]={dict:cur,str:i}; cur=cur[i] - elif set or '' in cur: return cur,'' + elif set_ and i!='': cur[i]={dict:cur,str:i}; cur=cur[i] + elif set_ or '' in cur: return cur,'' else: return None,None - if 1 in cur or set: return cur,1 + if 1 in cur or set_: return cur,1 raise "Corrupted data" def setDiscoHandler(self,handler,node='',jid=''): diff --git a/src/common/xmpp/commands.py b/src/common/xmpp/commands.py index 190e8f96d..6e6d3e92e 100644 --- a/src/common/xmpp/commands.py +++ b/src/common/xmpp/commands.py @@ -251,13 +251,13 @@ class Command_Handler_Prototype(PlugIn): # New session self.initial[action](conn,request) - def _DiscoHandler(self,conn,request,type): + def _DiscoHandler(self,conn,request,type_): """The handler for discovery events""" - if type == 'list': + if type_ == 'list': return (request.getTo(),self.name,self.description) - elif type == 'items': + elif type_ == 'items': return [] - elif type == 'info': + elif type_ == 'info': return self.discoinfo class TestCommand(Command_Handler_Prototype): diff --git a/src/common/xmpp/features.py b/src/common/xmpp/features.py index 7ca7b4f18..c5504dcb1 100644 --- a/src/common/xmpp/features.py +++ b/src/common/xmpp/features.py @@ -171,11 +171,11 @@ def setDefaultPrivacyList(disp,listname=None): """ Sets the default privacy list as 'listname'. Returns true on success.""" return setActivePrivacyList(disp,listname,'default') -def setPrivacyList(disp,list): +def setPrivacyList(disp,list_): """ Set the ruleset. 'list' should be the simpleXML node formatted according to RFC 3921 (XMPP-IM) (I.e. Node('list',{'name':listname},payload=[...]) ) Returns true on success.""" - resp=disp.SendAndWaitForResponse(Iq('set',NS_PRIVACY,payload=[list])) + resp=disp.SendAndWaitForResponse(Iq('set',NS_PRIVACY,payload=[list_])) if isResultNode(resp): return 1 def delPrivacyList(disp,listname): diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 283b3ab5b..c3e01de1b 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -360,7 +360,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): def get_status(self): return STATUS_LIST[self.connected] - def send_message(self, jid, msg, keyID, type = 'chat', subject='', + def send_message(self, jid, msg, keyID, type_ = 'chat', subject='', chatstate = None, msg_id = None, composing_xep = None, resource = None, user_nick = None, session=None, forward_from=None, form_node=None, original_message=None): fjid = jid @@ -396,8 +396,8 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): self.dispatch('MSGNOTSENT', (jid, error, msgtxt, tim, session)) return 3 - if type == 'chat': - msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type) + if type_ == 'chat': + msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type_) else: if subject: @@ -445,7 +445,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): log_msg = _('Subject: %(subject)s\n%(message)s') % \ {'subject': subject, 'message': msg} if log_msg: - if type == 'chat': + if type_ == 'chat': kind = 'chat_msg_sent' else: kind = 'single_msg_sent' diff --git a/src/config.py b/src/config.py index 270af72e5..fbb3973aa 100644 --- a/src/config.py +++ b/src/config.py @@ -759,12 +759,12 @@ class PreferencesWindow: [self.xml.get_widget('sounds_scrolledwindow'), self.xml.get_widget('browse_sounds_hbox')]) - def on_sounds_treemodel_row_changed(self, model, path, iter): - sound_event = model[iter][3].decode('utf-8') + def on_sounds_treemodel_row_changed(self, model, path, iter_): + sound_event = model[iter_][3].decode('utf-8') gajim.config.set_per('soundevents', sound_event, 'enabled', bool(model[path][0])) gajim.config.set_per('soundevents', sound_event, 'path', - model[iter][2].decode('utf-8')) + model[iter_][2].decode('utf-8')) gajim.interface.save_config() def update_text_tags(self): @@ -891,11 +891,11 @@ class PreferencesWindow: model = self.default_msg_tree.get_model() model[path][3] = not model[path][3] - def on_default_msg_treemodel_row_changed(self, model, path, iter): - status = model[iter][0] - message = model[iter][2].decode('utf-8') + def on_default_msg_treemodel_row_changed(self, model, path, iter_): + status = model[iter_][0] + message = model[iter_][2].decode('utf-8') gajim.config.set_per('defaultstatusmsg', status, 'enabled', - model[iter][3]) + model[iter_][3]) gajim.config.set_per('defaultstatusmsg', status, 'message', message) def on_default_status_expander_activate(self, expander): @@ -919,7 +919,7 @@ class PreferencesWindow: iter = model.iter_next(iter) gajim.interface.save_config() - def on_msg_treemodel_row_changed(self, model, path, iter): + def on_msg_treemodel_row_changed(self, model, path, iter_): self.save_status_messages(model) def on_msg_treemodel_row_deleted(self, model, path): diff --git a/src/conversation_textview.py b/src/conversation_textview.py index a5d5e84de..479a6a7ac 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -408,53 +408,53 @@ class ConversationTextview: self.smooth_id = None self.smooth_scroll_timer.cancel() - def show_xep0184_warning(self, id): - if id in self.xep0184_marks: + def show_xep0184_warning(self, id_): + if id_ in self.xep0184_marks: return buffer = self.tv.get_buffer() buffer.begin_user_action() - self.xep0184_marks[id] = buffer.create_mark(None, + self.xep0184_marks[id_] = buffer.create_mark(None, buffer.get_end_iter(), left_gravity=True) - self.xep0184_shown[id] = NOT_SHOWN + self.xep0184_shown[id_] = NOT_SHOWN def show_it(): - if (not id in self.xep0184_shown) or \ - self.xep0184_shown[id] == ALREADY_RECEIVED: + if (not id_ in self.xep0184_shown) or \ + self.xep0184_shown[id_] == ALREADY_RECEIVED: return False end_iter = buffer.get_iter_at_mark( - self.xep0184_marks[id]) + self.xep0184_marks[id_]) buffer.insert(end_iter, ' ') buffer.insert_pixbuf(end_iter, ConversationTextview.XEP0184_WARNING_PIXBUF) before_img_iter = buffer.get_iter_at_mark( - self.xep0184_marks[id]) + self.xep0184_marks[id_]) before_img_iter.forward_char() post_img_iter = before_img_iter.copy() post_img_iter.forward_char() buffer.apply_tag_by_name('xep0184-warning', before_img_iter, post_img_iter) - self.xep0184_shown[id] = SHOWN + self.xep0184_shown[id_] = SHOWN return False gobject.timeout_add_seconds(2, show_it) buffer.end_user_action() - def hide_xep0184_warning(self, id): - if id not in self.xep0184_marks: + def hide_xep0184_warning(self, id_): + if id_ not in self.xep0184_marks: return - if self.xep0184_shown[id] == NOT_SHOWN: - self.xep0184_shown[id] = ALREADY_RECEIVED + if self.xep0184_shown[id_] == NOT_SHOWN: + self.xep0184_shown[id_] = ALREADY_RECEIVED return buffer = self.tv.get_buffer() buffer.begin_user_action() - begin_iter = buffer.get_iter_at_mark(self.xep0184_marks[id]) + begin_iter = buffer.get_iter_at_mark(self.xep0184_marks[id_]) end_iter = begin_iter.copy() # XXX: Is there a nicer way? @@ -462,12 +462,12 @@ class ConversationTextview: end_iter.forward_char() buffer.delete(begin_iter, end_iter) - buffer.delete_mark(self.xep0184_marks[id]) + buffer.delete_mark(self.xep0184_marks[id_]) buffer.end_user_action() - del self.xep0184_marks[id] - del self.xep0184_shown[id] + del self.xep0184_marks[id_] + del self.xep0184_shown[id_] def show_focus_out_line(self): if not self.allow_focus_out_line: @@ -859,13 +859,13 @@ class ConversationTextview: menu.popup(None, None, None, event.button, event.time) - def hyperlink_handler(self, texttag, widget, event, iter, kind): + def hyperlink_handler(self, texttag, widget, event, iter_, kind): if event.type == gtk.gdk.BUTTON_PRESS: - begin_iter = iter.copy() + begin_iter = iter_.copy() # we get the begining of the tag while not begin_iter.begins_tag(texttag): begin_iter.backward_char() - end_iter = iter.copy() + end_iter = iter_.copy() # we get the end of the tag while not end_iter.ends_tag(texttag): end_iter.forward_char() @@ -877,7 +877,7 @@ class ConversationTextview: # we launch the correct application helpers.launch_browser_mailer(kind, word) - def html_hyperlink_handler(self, texttag, widget, event, iter, kind, href): + def html_hyperlink_handler(self, texttag, widget, event, iter_, kind, href): if event.type == gtk.gdk.BUTTON_PRESS: if event.button == 3: # right click self.make_link_menu(event, kind, href) @@ -922,7 +922,7 @@ class ConversationTextview: return index # the position after *last* special text - def latex_to_image(self, str): + def latex_to_image(self, str_): result = None exitcode = 0 @@ -938,11 +938,11 @@ class ConversationTextview: '\\item', '\\section', '\\mbox', '\\DeclareRobustCommand', '\\[', '\\]'] - str = str[2:len(str)-2] + str_ = str_[2:len(str_)-2] # filter latex code with bad commands for word in blacklist: - if word in str: + if word in str_: exitcode = 1 break @@ -956,7 +956,7 @@ class ConversationTextview: texstr += '\\usepackage{amsmath}\\usepackage{amssymb}' texstr += '\\pagestyle{empty}' texstr += '\\begin{document}\\begin{large}\\begin{gather*}' - texstr += str + texstr += str_ texstr += '\\end{gather*}\\end{large}\\end{document}' file = open(os.path.join(tmpfile + '.tex'), 'w+') diff --git a/src/dataforms_widget.py b/src/dataforms_widget.py index e69ad7222..cddd0e583 100644 --- a/src/dataforms_widget.py +++ b/src/dataforms_widget.py @@ -570,9 +570,9 @@ class SingleForm(gtk.Table, object): model = treeview.get_model() deleted = [] - def remove(model, path, iter, deleted): - deleted+=model[iter] - model.remove(iter) + def remove(model, path, iter_, deleted): + deleted+=model[iter_] + model.remove(iter_) selection.selected_foreach(remove, deleted) field.values = (v for v in field.values if v not in deleted) diff --git a/src/dialogs.py b/src/dialogs.py index faaba7d43..176bab6cb 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -309,12 +309,12 @@ class ChooseGPGKeyDialog: self.on_response(keyID) self.window.destroy() - def fill_tree(self, list, selected): + def fill_tree(self, list_, selected): model = self.keys_treeview.get_model() - for keyID in list.keys(): - iter = model.append((keyID, list[keyID])) + for keyID in list_.keys(): + iter_ = model.append((keyID, list_[keyID])) if keyID == selected: - path = model.get_path(iter) + path = model.get_path(iter_) self.keys_treeview.set_cursor(path) @@ -1104,12 +1104,12 @@ class Dialog(gtk.Dialog): class HigDialog(gtk.MessageDialog): - def __init__(self, parent, type, buttons, pritext, sectext, + def __init__(self, parent, type_, buttons, pritext, sectext, on_response_ok = None, on_response_cancel = None, on_response_yes = None, on_response_no = None): gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, - type, buttons, message_format = pritext) + type_, buttons, message_format = pritext) self.format_secondary_markup(sectext) @@ -2364,7 +2364,7 @@ class SingleMessageWindow: form_node = None # FIXME: allow GPG message some day gajim.connections[self.account].send_message(to_whom_jid, message, - keyID=None, type='normal', subject=subject, session=session, + keyID=None, type_='normal', subject=subject, session=session, form_node=form_node) self.subject_entry.set_text('') # we sent ok, clear the subject diff --git a/src/disco.py b/src/disco.py index 337ad5911..2557b84bc 100644 --- a/src/disco.py +++ b/src/disco.py @@ -240,9 +240,9 @@ class ServicesCache: self._items.cleanup() self._info.cleanup() - def _clean_closure(self, cb, type, addr): + def _clean_closure(self, cb, type_, addr): # A closure died, clean up - cbkey = (type, addr) + cbkey = (type_, addr) try: self._cbs[cbkey].remove(cb) except KeyError: @@ -989,20 +989,20 @@ _('This service does not contain any items to browse.')) get_agent_address(jid, node))) self.cache.get_info(jid, node, self._agent_info, force = force) - def _update_item(self, iter, jid, node, item): + def _update_item(self, iter_, jid, node, item): '''Called when an item should be updated in the model. The result of a disco#items query. (seldom)''' if 'name' in item: - self.model[iter][2] = item['name'] + self.model[iter_][2] = item['name'] - def _update_info(self, iter, jid, node, identities, features, data): + def _update_info(self, iter_, jid, node, identities, features, data): '''Called when an item should be updated in the model with further info. The result of a disco#info query.''' name = identities[0].get('name', '') if name: - self.model[iter][2] = name + self.model[iter_][2] = name - def _update_error(self, iter, jid, node): + def _update_error(self, iter_, jid, node): '''Called when a disco#info query failed for an item.''' pass @@ -1024,21 +1024,21 @@ class ToplevelAgentBrowser(AgentBrowser): self._view_signals = [] self._scroll_signal = None - def _pixbuf_renderer_data_func(self, col, cell, model, iter): + def _pixbuf_renderer_data_func(self, col, cell, model, iter_): '''Callback for setting the pixbuf renderer's properties.''' - jid = model.get_value(iter, 0) + jid = model.get_value(iter_, 0) if jid: - pix = model.get_value(iter, 2) + pix = model.get_value(iter_, 2) cell.set_property('visible', True) cell.set_property('pixbuf', pix) else: cell.set_property('visible', False) - def _text_renderer_data_func(self, col, cell, model, iter): + def _text_renderer_data_func(self, col, cell, model, iter_): '''Callback for setting the text renderer's properties.''' - jid = model.get_value(iter, 0) - markup = model.get_value(iter, 3) - state = model.get_value(iter, 4) + jid = model.get_value(iter_, 0) + markup = model.get_value(iter_, 3) + state = model.get_value(iter_, 4) cell.set_property('markup', markup) if jid: cell.set_property('cell_background_set', False) @@ -1407,13 +1407,13 @@ class ToplevelAgentBrowser(AgentBrowser): self.window.progressbar.hide() return False - def _friendly_category(self, category, type=None): + def _friendly_category(self, category, type_=None): '''Get the friendly category name and priority.''' cat = None - if type: + if type_: # Try type-specific override try: - cat, prio = _cat_to_descr[(category, type)] + cat, prio = _cat_to_descr[(category, type_)] except KeyError: pass if not cat: @@ -1423,14 +1423,14 @@ class ToplevelAgentBrowser(AgentBrowser): cat, prio = _cat_to_descr['other'] return cat, prio - def _create_category(self, cat, type=None): + def _create_category(self, cat, type_=None): '''Creates a category row.''' - cat, prio = self._friendly_category(cat, type) + cat, prio = self._friendly_category(cat, type_) return self.model.append(None, ('', '', None, cat, prio)) - def _find_category(self, cat, type=None): + def _find_category(self, cat, type_=None): '''Looks up a category row and returns the iterator to it, or None.''' - cat, prio = self._friendly_category(cat, type) + cat, prio = self._friendly_category(cat, type_) iter = self.model.get_iter_root() while iter: if self.model.get_value(iter, 3).decode('utf-8') == cat: @@ -1486,15 +1486,15 @@ class ToplevelAgentBrowser(AgentBrowser): self.cache.get_info(jid, node, self._agent_info, force = force) self._update_progressbar() - def _update_item(self, iter, jid, node, item): + def _update_item(self, iter_, jid, node, item): addr = get_agent_address(jid, node) if 'name' in item: descr = "<b>%s</b>\n%s" % (item['name'], addr) else: descr = "<b>%s</b>" % addr - self.model[iter][3] = descr + self.model[iter_][3] = descr - def _update_info(self, iter, jid, node, identities, features, data): + def _update_info(self, iter_, jid, node, identities, features, data): addr = get_agent_address(jid, node) name = identities[0].get('name', '') if name: @@ -1516,16 +1516,16 @@ class ToplevelAgentBrowser(AgentBrowser): break # Check if we have to move categories - old_cat_iter = self.model.iter_parent(iter) + old_cat_iter = self.model.iter_parent(iter_) old_cat = self.model.get_value(old_cat_iter, 3).decode('utf-8') if self.model.get_value(old_cat_iter, 3) == cat: # Already in the right category, just update - self.model[iter][2] = pix - self.model[iter][3] = descr - self.model[iter][4] = 0 + self.model[iter_][2] = pix + self.model[iter_][3] = descr + self.model[iter_][4] = 0 return # Not in the right category, move it. - self.model.remove(iter) + self.model.remove(iter_) # Check if the old category is empty if not self.model.iter_is_valid(old_cat_iter): @@ -1539,9 +1539,9 @@ class ToplevelAgentBrowser(AgentBrowser): self.model.append(cat_iter, (jid, node, pix, descr, 0)) self._expand_all() - def _update_error(self, iter, jid, node): + def _update_error(self, iter_, jid, node): addr = get_agent_address(jid, node) - self.model[iter][4] = 2 + self.model[iter_][4] = 2 self._progress += 1 self._update_progressbar() @@ -1738,7 +1738,7 @@ class MucBrowser(AgentBrowser): if not self._fetch_source: self._fetch_source = gobject.idle_add(self._start_info_query) - def _update_info(self, iter, jid, node, identities, features, data): + def _update_info(self, iter_, jid, node, identities, features, data): name = identities[0].get('name', '') for form in data: typefield = form.getField('FORM_TYPE') @@ -1748,15 +1748,15 @@ class MucBrowser(AgentBrowser): users = form.getField('muc#roominfo_occupants') descr = form.getField('muc#roominfo_description') if users: - self.model[iter][3] = int(users.getValue()) - self.model[iter][4] = users.getValue() + self.model[iter_][3] = int(users.getValue()) + self.model[iter_][4] = users.getValue() if descr: - self.model[iter][5] = descr.getValue() + self.model[iter_][5] = descr.getValue() # Only set these when we find a form with additional info # Some servers don't support forms and put extra info in # the name attribute, so we preserve it in that case. - self.model[iter][2] = name - self.model[iter][6] = True + self.model[iter_][2] = name + self.model[iter_][6] = True break else: # We didn't find a form, switch to alternate query mode @@ -1766,7 +1766,7 @@ class MucBrowser(AgentBrowser): self._fetch_source = None self._query_visible() - def _update_error(self, iter, jid, node): + def _update_error(self, iter_, jid, node): # switch to alternate query mode self.cache.get_items(jid, node, self._channel_altinfo) @@ -1836,7 +1836,7 @@ class DiscussionGroupsBrowser(AgentBrowser): self._total_items += 1 self._add_item(jid, node, item, force) - def _in_list_foreach(self, model, path, iter, node): + def _in_list_foreach(self, model, path, iter_, node): if model[path][1] == node: self.in_list = True diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 84f53d52e..16f9dd083 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -458,8 +458,8 @@ _('Connection with peer cannot be established.')) eta = remaining_size / speed return eta, speed - def _remove_transfer(self, iter, sid, file_props): - self.model.remove(iter) + def _remove_transfer(self, iter_, sid, file_props): + self.model.remove(iter_) if 'tt_account' in file_props: # file transfer is set account = file_props['tt_account'] @@ -484,7 +484,7 @@ _('Connection with peer cannot be established.')) del(self.files_props[sid[0]][sid[1:]]) del(file_props) - def set_progress(self, typ, sid, transfered_size, iter = None): + def set_progress(self, typ, sid, transfered_size, iter_ = None): ''' change the progress of a transfer with new transfered size''' if sid not in self.files_props[typ]: return @@ -494,11 +494,11 @@ _('Connection with peer cannot be established.')) percent = 0 else: percent = round(float(transfered_size) / full_size * 100, 1) - if iter is None: - iter = self.get_iter_by_sid(typ, sid) - if iter is not None: + if iter_ is None: + iter_ = self.get_iter_by_sid(typ, sid) + if iter_ is not None: just_began = False - if self.model[iter][C_PERCENT] == 0 and int(percent > 0): + if self.model[iter_][C_PERCENT] == 0 and int(percent > 0): just_began = True text = self._format_percent(percent) if transfered_size == 0: @@ -520,8 +520,8 @@ _('Connection with peer cannot be established.')) eta, speed = self._get_eta_and_speed(full_size, transfered_size, file_props) - self.model.set(iter, C_PROGRESS, text) - self.model.set(iter, C_PERCENT, int(percent)) + self.model.set(iter_, C_PROGRESS, text) + self.model.set(iter_, C_PERCENT, int(percent)) text = self._format_time(eta) text += '\n' #This should make the string Kb/s, @@ -529,7 +529,7 @@ _('Connection with peer cannot be established.')) #Only the 's' after / (which means second) should be translated. text += _('(%(filesize_unit)s/s)') % {'filesize_unit': helpers.convert_bytes(speed)} - self.model.set(iter, C_TIME, text) + self.model.set(iter_, C_TIME, text) # try to guess what should be the status image if file_props['type'] == 'r': @@ -542,11 +542,11 @@ _('Connection with peer cannot be established.')) status = 'waiting' if 'connected' in file_props and file_props['connected'] == False: status = 'stop' - self.model.set(iter, 0, self.images[status]) + self.model.set(iter_, 0, self.images[status]) if transfered_size == full_size: self.set_status(typ, sid, 'ok') elif just_began: - path = self.model.get_path(iter) + path = self.model.get_path(iter_) self.select_func(path) def get_iter_by_sid(self, typ, sid): @@ -873,11 +873,11 @@ _('Connection with peer cannot be established.')) def on_close_button_clicked(self, widget): self.window.hide() - def show_context_menu(self, event, iter): + def show_context_menu(self, event, iter_): # change the sensitive propery of the buttons and menuitems path = None - if iter is not None: - path = self.model.get_path(iter) + if iter_ is not None: + path = self.model.get_path(iter_) self.set_buttons_sensitive(path, True) event_button = gtkgui_helpers.get_possible_button_event(event) diff --git a/src/gajim.py b/src/gajim.py index c1872255f..9a1001c0b 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2307,7 +2307,8 @@ class Interface: room_jid = room_jid, name = nick, show = show) if not session: - session = gajim.connections[account].make_new_session(fjid, None, type='pm') + session = gajim.connections[account].make_new_session( + fjid, None, type_='pm') self.new_private_chat(gc_contact, account, session=session) ctrl = session.control diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 9f89dbb92..0fd6f5306 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -66,19 +66,19 @@ def set_renderer_color(treeview, renderer, set_background = True): fgcolor = treeview.style.fg[gtk.STATE_PRELIGHT] renderer.set_property('foreground-gdk', fgcolor) -def tree_cell_data_func(column, renderer, model, iter, tv=None): +def tree_cell_data_func(column, renderer, model, iter_, tv=None): # cell data func is global, because we don't want it to keep # reference to GroupchatControl instance (self) theme = gajim.config.get('roster_theme') # allocate space for avatar only if needed - parent_iter = model.iter_parent(iter) + parent_iter = model.iter_parent(iter_) if isinstance(renderer, gtk.CellRendererPixbuf): avatar_position = gajim.config.get('avatar_position_in_roster') if avatar_position == 'right': renderer.set_property('xalign', 1) # align pixbuf to the right else: renderer.set_property('xalign', 0.5) - if parent_iter and (model[iter][C_AVATAR] or avatar_position == 'left'): + if parent_iter and (model[iter_][C_AVATAR] or avatar_position == 'left'): renderer.set_property('visible', True) renderer.set_property('width', gajim.config.get('roster_avatar_width')) else: @@ -541,8 +541,8 @@ class GroupchatControl(ChatControlBase): for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): self.draw_contact(nick) - def _change_style(self, model, path, iter): - model[iter][C_NICK] = model[iter][C_NICK] + def _change_style(self, model, path, iter_): + model[iter_][C_NICK] = model[iter_][C_NICK] def change_roster_style(self): model = self.list_treeview.get_model() @@ -982,12 +982,12 @@ class GroupchatControl(ChatControlBase): # Recalculate column width for ellipsizin self.list_treeview.columns_autosize() - def on_send_pm(self, widget=None, model=None, iter=None, nick=None, + def on_send_pm(self, widget=None, model=None, iter_=None, nick=None, msg=None): '''opens a chat window and if msg is not None sends private message to a contact in a room''' if nick is None: - nick = model[iter][C_NICK].decode('utf-8') + nick = model[iter_][C_NICK].decode('utf-8') fjid = gajim.construct_fjid(self.room_jid, nick) # 'fake' jid ctrl = self._start_private_message(nick) @@ -2040,17 +2040,17 @@ class GroupchatControl(ChatControlBase): widget.get_selection().unselect_all() return True - def on_list_treeview_row_expanded(self, widget, iter, path): + def on_list_treeview_row_expanded(self, widget, iter_, path): '''When a row is expanded: change the icon of the arrow''' model = widget.get_model() image = gajim.interface.jabber_state_images['16']['opened'] - model[iter][C_IMG] = image + model[iter_][C_IMG] = image - def on_list_treeview_row_collapsed(self, widget, iter, path): + def on_list_treeview_row_collapsed(self, widget, iter_, path): '''When a row is collapsed: change the icon of the arrow''' model = widget.get_model() image = gajim.interface.jabber_state_images['16']['closed'] - model[iter][C_IMG] = image + model[iter_][C_IMG] = image def kick(self, widget, nick): '''kick a user''' @@ -2062,10 +2062,10 @@ class GroupchatControl(ChatControlBase): instance = dialogs.InputDialog(_('Kicking %s') % nick, _('You may specify a reason below:'), ok_handler=on_ok) - def mk_menu(self, event, iter): + def mk_menu(self, event, iter_): '''Make contact's popup menu''' model = self.list_treeview.get_model() - nick = model[iter][C_NICK].decode('utf-8') + nick = model[iter_][C_NICK].decode('utf-8') c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) jid = c.jid target_affiliation = c.affiliation @@ -2159,7 +2159,7 @@ class GroupchatControl(ChatControlBase): self.handlers[id] = item item = xml.get_widget('send_private_message_menuitem') - id = item.connect('activate', self.on_send_pm, model, iter) + id = item.connect('activate', self.on_send_pm, model, iter_) self.handlers[id] = item item = xml.get_widget('send_file_menuitem') diff --git a/src/gtkexcepthook.py b/src/gtkexcepthook.py index 04470cae0..114cfaf9e 100644 --- a/src/gtkexcepthook.py +++ b/src/gtkexcepthook.py @@ -35,11 +35,11 @@ from common import helpers _exception_in_progress = threading.Lock() -def _info(type, value, tb): +def _info(type_, value, tb): if not _exception_in_progress.acquire(False): # Exceptions have piled up, so we use the default exception # handler for such exceptions - _excepthook_save(type, value, tb) + _excepthook_save(type_, value, tb) return dialog = dialogs.HigDialog(None, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, @@ -69,7 +69,7 @@ def _info(type, value, tb): frame.set_border_width(6) textbuffer = textview.get_buffer() trace = StringIO() - traceback.print_exception(type, value, tb, None, trace) + traceback.print_exception(type_, value, tb, None, trace) textbuffer.set_text(trace.getvalue()) textview.set_size_request( gtk.gdk.screen_width() / 3, diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index f83e22882..6900a856a 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -273,10 +273,10 @@ class HashDigest: self.algo = self.cleanID(algo) self.digest = self.cleanID(digest) - def cleanID(self, id): - id = id.strip().lower() - for strip in (' :.-_'): id = id.replace(strip, '') - return id + def cleanID(self, id_): + id_ = id_.strip().lower() + for strip in (' :.-_'): id_ = id_.replace(strip, '') + return id_ def __eq__(self, other): sa, sd = self.algo, self.digest diff --git a/src/htmltextview.py b/src/htmltextview.py index 601c56931..adfba4541 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -728,7 +728,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): else: self._insert_text(text.strip('\n')) - def _anchor_event(self, tag, textview, event, iter, href, type_): + def _anchor_event(self, tag, textview, event, iter_, href, type_): if event.type == gtk.gdk.BUTTON_PRESS: self.textview.emit('url-clicked', href, type_) return True @@ -1068,7 +1068,7 @@ if __name__ == '__main__': htmlview.connect('motion_notify_event', on_textview_motion_notify_event) - def handler(texttag, widget, event, iter, kind, href): + def handler(texttag, widget, event, iter_, kind, href): if event.type == gtk.gdk.BUTTON_PRESS: print href diff --git a/src/message_control.py b/src/message_control.py index 88923e625..7172b7e65 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -160,7 +160,7 @@ class MessageControl: if crypto_changed: self.print_esession_details() - def send_message(self, message, keyID = '', type = 'chat', + def send_message(self, message, keyID = '', type_ = 'chat', chatstate = None, msg_id = None, composing_xep = None, resource = None, user_nick = None): # Send the given message to the active tab. @@ -184,7 +184,7 @@ class MessageControl: self.set_session(sess) # Send and update history - return conn.send_message(jid, message, keyID, type = type, + return conn.send_message(jid, message, keyID, type_ = type_, chatstate = chatstate, msg_id = msg_id, composing_xep = composing_xep, resource = self.resource, user_nick = user_nick, diff --git a/src/message_window.py b/src/message_window.py index cd4a1d820..e13c40455 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -55,7 +55,7 @@ class MessageWindow(object): CLOSE_CTRL_KEY ) = range(5) - def __init__(self, acct, type, parent_window=None, parent_paned=None): + def __init__(self, acct, type_, parent_window=None, parent_paned=None): # A dictionary of dictionaries # where _contacts[account][jid] == A MessageControl self._controls = {} @@ -63,7 +63,7 @@ class MessageWindow(object): # If None, the window is not tied to any specific account self.account = acct # If None, the window is not tied to any specific type - self.type = type + self.type_ = type_ # dict { handler id: widget}. Keeps callbacks, which # lead to cylcular references self.handlers = {} @@ -773,7 +773,7 @@ class MessageWindow(object): selection.set(selection.target, 8, str(source_page_num)) def on_tab_label_drag_data_received_cb(self, widget, drag_context, x, y, - selection, type, time): + selection, type_, time): '''Reorder the tabs according to the drop position''' source_page_num = int(selection.data) dest_page_num, to_right = self.get_tab_at_xy(x, y) @@ -869,13 +869,13 @@ class MessageWindowMgr(gobject.GObject): for win in self.windows(): win.change_account_name(old_name, new_name) - def _new_window(self, acct, type): + def _new_window(self, acct, type_): parent_win = None parent_paned = None if self.mode == self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: parent_win = self.parent_win parent_paned = self.parent_paned - win = MessageWindow(acct, type, parent_win, parent_paned) + win = MessageWindow(acct, type_, parent_win, parent_paned) # we track the lifetime of this window win.window.connect('delete-event', self._on_window_delete) win.window.connect('destroy', self._on_window_destroy) @@ -897,14 +897,14 @@ class MessageWindowMgr(gobject.GObject): def has_window(self, jid, acct): return self.get_window(jid, acct) is not None - def one_window_opened(self, contact=None, acct=None, type=None): + def one_window_opened(self, contact=None, acct=None, type_=None): try: return \ - self._windows[self._mode_to_key(contact, acct, type)] is not None + self._windows[self._mode_to_key(contact, acct, type_)] is not None except KeyError: return False - def _resize_window(self, win, acct, type): + def _resize_window(self, win, acct, type_): '''Resizes window according to config settings''' if self.mode in (self.ONE_MSG_WINDOW_ALWAYS, self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER): @@ -920,10 +920,10 @@ class MessageWindowMgr(gobject.GObject): size = (gajim.config.get_per('accounts', acct, 'msgwin-width'), gajim.config.get_per('accounts', acct, 'msgwin-height')) elif self.mode in (self.ONE_MSG_WINDOW_NEVER, self.ONE_MSG_WINDOW_PERTYPE): - if type == message_control.TYPE_PM: - type = message_control.TYPE_CHAT - opt_width = type + '-msgwin-width' - opt_height = type + '-msgwin-height' + if type_ == message_control.TYPE_PM: + type_ = message_control.TYPE_CHAT + opt_width = type_ + '-msgwin-width' + opt_height = type_ + '-msgwin-height' size = (gajim.config.get(opt_width), gajim.config.get(opt_height)) else: return @@ -931,7 +931,7 @@ class MessageWindowMgr(gobject.GObject): if win.parent_paned: win.parent_paned.set_position(parent_size[0]) - def _position_window(self, win, acct, type): + def _position_window(self, win, acct, type_): '''Moves window according to config settings''' if (self.mode in [self.ONE_MSG_WINDOW_NEVER, self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER]): @@ -944,14 +944,14 @@ class MessageWindowMgr(gobject.GObject): pos = (gajim.config.get_per('accounts', acct, 'msgwin-x-position'), gajim.config.get_per('accounts', acct, 'msgwin-y-position')) elif self.mode == self.ONE_MSG_WINDOW_PERTYPE: - pos = (gajim.config.get(type + '-msgwin-x-position'), - gajim.config.get(type + '-msgwin-y-position')) + pos = (gajim.config.get(type_ + '-msgwin-x-position'), + gajim.config.get(type_ + '-msgwin-y-position')) else: return gtkgui_helpers.move_window(win.window, pos[0], pos[1]) - def _mode_to_key(self, contact, acct, type, resource = None): + def _mode_to_key(self, contact, acct, type_, resource = None): if self.mode == self.ONE_MSG_WINDOW_NEVER: key = acct + contact.jid if resource: @@ -964,22 +964,22 @@ class MessageWindowMgr(gobject.GObject): elif self.mode == self.ONE_MSG_WINDOW_PERACCT: return acct elif self.mode == self.ONE_MSG_WINDOW_PERTYPE: - return type + return type_ - def create_window(self, contact, acct, type, resource = None): + def create_window(self, contact, acct, type_, resource = None): win_acct = None win_type = None win_role = None # X11 window role - win_key = self._mode_to_key(contact, acct, type, resource) + win_key = self._mode_to_key(contact, acct, type_, resource) if self.mode == self.ONE_MSG_WINDOW_PERACCT: win_acct = acct win_role = acct elif self.mode == self.ONE_MSG_WINDOW_PERTYPE: - win_type = type - win_role = type + win_type = type_ + win_role = type_ elif self.mode == self.ONE_MSG_WINDOW_NEVER: - win_type = type + win_type = type_ win_role = contact.jid elif self.mode == self.ONE_MSG_WINDOW_ALWAYS: win_role = 'messages' @@ -994,9 +994,9 @@ class MessageWindowMgr(gobject.GObject): win.window.set_role(win_role) # Position and size window based on saved state and window mode - if not self.one_window_opened(contact, acct, type): - self._resize_window(win, acct, type) - self._position_window(win, acct, type) + if not self.one_window_opened(contact, acct, type_): + self._resize_window(win, acct, type_) + self._position_window(win, acct, type_) self._windows[win_key] = win return win @@ -1039,12 +1039,12 @@ May be useful some day in the future?''' return ctrl return None - def get_controls(self, type = None, acct = None): + def get_controls(self, type_ = None, acct = None): ctrls = [] for c in self.controls(): if acct and c.account != acct: continue - if not type or c.type_id == type: + if not type_ or c.type_id == type_: ctrls.append(c) return ctrls diff --git a/src/notify.py b/src/notify.py index 01fa1148d..0d5a4bfb8 100644 --- a/src/notify.py +++ b/src/notify.py @@ -400,12 +400,12 @@ class NotificationResponseManager: self.interface.connect_to_signal('ActionInvoked', self.on_action_invoked) self.interface.connect_to_signal('NotificationClosed', self.on_closed) - def on_action_invoked(self, id, reason): - self.received.append((id, time.time(), reason)) - if id in self.pending: - notification = self.pending[id] - notification.on_action_invoked(id, reason) - del self.pending[id] + def on_action_invoked(self, id_, reason): + self.received.append((id_, time.time(), reason)) + if id_ in self.pending: + notification = self.pending[id_] + notification.on_action_invoked(id_, reason) + del self.pending[id_] if len(self.received) > 20: curt = time.time() for rec in self.received: @@ -413,21 +413,21 @@ class NotificationResponseManager: if diff > 10: self.received.remove(rec) - def on_closed(self, id, reason=None): - if id in self.pending: - del self.pending[id] + def on_closed(self, id_, reason=None): + if id_ in self.pending: + del self.pending[id_] - def add_pending(self, id, object): + def add_pending(self, id_, object_): # Check to make sure that we handle an event immediately if we're adding # an id that's already been triggered for rec in self.received: - if rec[0] == id: - object.on_action_invoked(id, rec[2]) + if rec[0] == id_: + object_.on_action_invoked(id_, rec[2]) self.received.remove(rec) return - if id not in self.pending: + if id_ not in self.pending: # Add it - self.pending[id] = object + self.pending[id_] = object_ else: # We've triggered an event that has a duplicate ID! gajim.log.debug('Duplicate ID of notification. Can\'t handle this.') @@ -553,8 +553,8 @@ class DesktopNotification: reply_handler=self.attach_by_id, error_handler=self.notify_another_way) - def attach_by_id(self, id): - self.id = id + def attach_by_id(self, id_): + self.id = id_ notification_response_manager.attach_to_interface() notification_response_manager.add_pending(self.id, self) @@ -562,10 +562,10 @@ class DesktopNotification: gajim.log.debug(str(e)) gajim.log.debug('Need to implement a new way of falling back') - def on_action_invoked(self, id, reason): + def on_action_invoked(self, id_, reason): if self.notif is None: return - self.notif.CloseNotification(dbus.UInt32(id)) + self.notif.CloseNotification(dbus.UInt32(id_)) self.notif = None gajim.interface.handle_event(self.account, self.jid, self.msg_type) diff --git a/src/remote_control.py b/src/remote_control.py index 62d3f8b68..75e9606e9 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -279,7 +279,7 @@ class SignalObject(dbus.service.Object): return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) - def _send_message(self, jid, message, keyID, account, type = 'chat', + def _send_message(self, jid, message, keyID, account, type_ = 'chat', subject = None): '''can be called from send_chat_message (default when send_message) or send_single_message''' @@ -291,7 +291,7 @@ class SignalObject(dbus.service.Object): connected_account, contact = self._get_account_and_contact(account, jid) if connected_account: connection = gajim.connections[connected_account] - connection.send_message(jid, message, keyID, type, subject) + connection.send_message(jid, message, keyID, type_, subject) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) diff --git a/src/session.py b/src/session.py index 4f198ffb8..fadada2e6 100644 --- a/src/session.py +++ b/src/session.py @@ -38,9 +38,9 @@ import dialogs import negotiation class ChatControlSession(stanza_session.EncryptedStanzaSession): - def __init__(self, conn, jid, thread_id, type='chat'): + def __init__(self, conn, jid, thread_id, type_='chat'): stanza_session.EncryptedStanzaSession.__init__(self, conn, jid, thread_id, - type='chat') + type_='chat') self.control = None |