changeset 2506:426a8cb8e44c

Merge with devel.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 05:43:52 +0200
parents 09afb8020b20 (current diff) 0a90c1bad60f (diff)
children ea255685d6b0
files
diffstat 6 files changed, 41 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/events/emailnotify.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/MoinMoin/events/emailnotify.py	Sun Jul 22 05:43:52 2007 +0200
@@ -107,8 +107,8 @@
 
     data = notification.user_created_message(event.request, sitename, username, email)
 
-    for id in user_ids:
-        usr = User(event.request, id=id)
+    for usr_id in user_ids:
+        usr = User(event.request, id=usr_id)
 
         # Currently send this only to super users
         if usr.isSuperUser() and event_name in usr.email_subscribed_events:
--- a/MoinMoin/events/jabbernotify.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Sun Jul 22 05:43:52 2007 +0200
@@ -149,7 +149,7 @@
     send_notification(event.request, jids, data['body'], data['subject'])
 
 
-def page_change(type, request, page, subscribers, **kwargs):
+def page_change(change_type, request, page, subscribers, **kwargs):
     """Sends notification about page being changed in some way"""
     _ = request.getText
 
@@ -160,7 +160,7 @@
         for lang in subscribers:
             jids = [u.jid for u in subscribers[lang] if u.jid]
             names = [u.name for u in subscribers[lang] if u.jid]
-            msg = notification.page_change_message(type, request, page, lang, **kwargs)
+            msg = notification.page_change_message(change_type, request, page, lang, **kwargs)
             result = send_notification(request, jids, msg)
 
             if result:
--- a/MoinMoin/events/notification.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/MoinMoin/events/notification.py	Sun Jul 22 05:43:52 2007 +0200
@@ -42,7 +42,7 @@
         """
         self.recipients = recipients
 
-class UnknownChangeType:
+class UnknownChangeType(Exception):
     """ Used to signal an invalid page change event """
     pass
 
@@ -73,7 +73,7 @@
     pagelink = request.getQualifiedURL(page.url(request, querystr, relative=False))
 
     if msgtype == "page_changed":
-        messageBody = _("Dear Wiki user,\n\n"
+        msg_body = _("Dear Wiki user,\n\n"
         'You have subscribed to a wiki page or wiki category on "%(sitename)s" for change notification.\n\n'
         "The following page has been changed by %(editor)s:\n"
         "%(pagelink)s\n\n", formatted=False) % {
@@ -84,19 +84,19 @@
 
         # append a diff (or append full page text if there is no diff)
         if len(revisions) < 2:
-            messageBody = messageBody + \
+            messageBody = msg_body + \
                 _("New page:\n", formatted=False) + \
                 page.get_raw_body()
         else:
             lines = wikiutil.pagediff(request, page.page_name, revisions[1],
                                       page.page_name, revisions[0])
             if lines:
-                messageBody = messageBody + "%s\n%s\n" % (("-" * 78), '\n'.join(lines))
+                msg_body = msg_body + "%s\n%s\n" % (("-" * 78), '\n'.join(lines))
             else:
-                messageBody = messageBody + _("No differences found!\n", formatted=False)
+                msg_body = msg_body + _("No differences found!\n", formatted=False)
 
     elif msgtype == "page_deleted":
-        messageBody = _("Dear wiki user,\n\n"
+        msg_body = _("Dear wiki user,\n\n"
             'You have subscribed to a wiki page "%(sitename)s" for change notification.\n\n'
             "The following page has been deleted by %(editor)s:\n"
             "%(pagelink)s\n\n", formatted=False) % {
@@ -106,7 +106,7 @@
         }
 
     elif msgtype == "page_renamed":
-        messageBody = _("Dear wiki user,\n\n"
+        msg_body = _("Dear wiki user,\n\n"
             'You have subscribed to a wiki page "%(sitename)s" for change notification.\n\n'
             "The following page has been renamed from %(oldname)s by %(editor)s:\n"
             "%(pagelink)s\n\n", formatted=False) % {
@@ -119,10 +119,10 @@
         raise UnknownChangeType()
 
     if 'comment' in kwargs and kwargs['comment']:
-        messageBody = messageBody + \
+        msg_body = msg_body + \
             _("The comment on the change is:\n%(comment)s", formatted=False) % {'comment': kwargs['comment']}
 
-    return messageBody
+    return msg_body
 
 def user_created_message(request, sitename, username, email):
     """Formats a message used to notify about accounts being created
--- a/jabberbot/i18n.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/jabberbot/i18n.py	Sun Jul 22 05:43:52 2007 +0200
@@ -7,10 +7,10 @@
 """
 import logging, xmlrpclib
 
-translations = None
+TRANSLATIONS = None
 
 
-def getText(original, lang="en"):
+def get_text(original, lang="en"):
     """ Return a translation of text in the user's language.
 
         @type original: unicode
@@ -18,12 +18,12 @@
     if original == u"":
         return u""
 
-    global translations
-    if not translations:
+    global TRANSLATIONS
+    if not TRANSLATIONS:
         init_i18n()
 
     try:
-        return translations[lang][original]
+        return TRANSLATIONS[lang][original]
     except KeyError:
         return original
 
@@ -34,8 +34,8 @@
     @type config: jabberbot.config.BotConfig
 
     """
-    global translations
-    translations = request_translations(config) or {'en': {}}
+    global TRANSLATIONS
+    TRANSLATIONS = request_translations(config) or {'en': {}}
 
 
 def request_translations(config):
--- a/jabberbot/xmlrpcbot.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/jabberbot/xmlrpcbot.py	Sun Jul 22 05:43:52 2007 +0200
@@ -6,18 +6,19 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import datetime, logging, time, xmlrpclib, Queue
+import logging, xmlrpclib, Queue
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 from threading import Thread
 
 import jabberbot.commands as cmd
 from jabberbot.multicall import MultiCall
-from jabberbot.i18n import getText
+from jabberbot.i18n import get_text
 
-_ = getText
+_ = get_text
 
 class ConfigurationError(Exception):
     def __init__(self, message):
+        Exception.__init__()
         self.message = message
 
 class XMLRPCClient(Thread):
@@ -207,7 +208,7 @@
         else:
             token_result, getpageinfo_result = self.multicall()
             if token_result != u"SUCCESS":
-                self.warn_no_credentials(jid)
+                self.warn_no_credentials(command.jid)
 
         author = getpageinfo_result['author']
         if author.startswith("Self:"):
--- a/jabberbot/xmppbot.py	Sun Jul 22 05:11:46 2007 +0200
+++ b/jabberbot/xmppbot.py	Sun Jul 22 05:43:52 2007 +0200
@@ -68,10 +68,12 @@
         self.last_online = None
 
     def set_supports_forms(self, resource):
+        """Flag the given resource as supporting Data Forms"""
         if resource in self.resources:
             self.resources[resource]["forms"] = True
 
     def supports_forms(self, resource):
+        """Check if the given resource supports Data Forms"""
         if resource in self.resources:
             return self.resources[resource]["forms"]
         else:
@@ -212,8 +214,8 @@
             if not contact.is_valid(current_time):
                 del self.contacts[jid]
 
-    def getText(self, jid):
-        """Returns a getText function (_) for the given JID
+    def get_text(self, jid):
+        """Returns a gettext function (_) for the given JID
 
         @param jid: bare Jabber ID of the user we're going to communicate with
         @type jid: str or pyxmpp.jid.JID
@@ -228,7 +230,7 @@
         if jid in self.contacts:
             language = self.contacts[jid].language
 
-        return lambda text: i18n.getText(text, lang=language)
+        return lambda text: i18n.get_text(text, lang=language)
 
     def poll_commands(self):
         """Checks for new commands in the input queue and executes them
@@ -272,7 +274,7 @@
 
             return
 
-        _ = self.getText(command.jid)
+        _ = self.get_text(command.jid)
 
         # Handle subscribtion management commands
         if isinstance(command, cmd.AddJIDToRosterCommand):
@@ -333,7 +335,7 @@
         stanza = Presence(to_jid=jid, stanza_type="unsubscribed")
         self.get_stream().send(stanza)
 
-    def send_message(self, jid, text, subject="", msg_type=u"chat", form=None):
+    def send_message(self, jid, text, subject="", msg_type=u"chat"):
         """Sends a message
 
         @param jid: JID to send the message to
@@ -349,7 +351,7 @@
         pass
 
     def send_search_form(self, jid):
-        _ = self.getText(jid)
+        _ = self.get_text(jid)
 
         # These encode()s may look weird, but due to some pyxmpp oddness we have
         # to provide an utf-8 string instead of unicode. Bug reported, patches submitted...
@@ -378,8 +380,8 @@
         @type command: unicode
 
         """
-        for cmd in self.internal_commands:
-            if cmd.lower() == command:
+        for internal_cmd in self.internal_commands:
+            if internal_cmd.lower() == command:
                 return True
 
         return False
@@ -390,8 +392,8 @@
         @type command: unicode
 
         """
-        for cmd in self.xmlrpc_commands:
-            if cmd.lower() == command:
+        for xmlrpc_cmd in self.xmlrpc_commands:
+            if xmlrpc_cmd.lower() == command:
                 return True
 
         return False
@@ -433,7 +435,7 @@
         @type sender: pyxmpp.jid.JID
 
         """
-        _ = self.getText(sender)
+        _ = self.get_text(sender)
 
         if command[0] == "ping":
             return "pong"
@@ -476,7 +478,7 @@
         @return: a help message
 
         """
-        _ = self.getText(jid)
+        _ = self.get_text(jid)
 
         if command == "help":
             return _("""The "help" command prints a short, helpful message \
@@ -508,7 +510,7 @@
         @type command: list representing a command, name and parameters
 
         """
-        _ = self.getText(sender)
+        _ = self.get_text(sender)
         command_class = self.xmlrpc_commands[command[0]]
 
         # Add sender's JID to the argument list
@@ -681,7 +683,7 @@
         It's sent in response to an uknown message or the "help" command.
 
         """
-        _ = self.getText(jid)
+        _ = self.get_text(jid)
 
         msg = _("Hello there! I'm a MoinMoin Notification Bot. Available commands:\
 \n\n%(internal)s\n%(xmlrpc)s")