changeset 5280:d25574af97eb

event package: fix PEP8, c&p errors, trivial code changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 15 Nov 2009 10:23:51 +0100
parents 2aa43685e17b
children 5f0ec1f315bc
files MoinMoin/events/__init__.py MoinMoin/events/emailnotify.py MoinMoin/events/jabbernotify.py MoinMoin/events/notification.py MoinMoin/events/xapian_index.py
diffstat 5 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/events/__init__.py	Sun Nov 15 10:08:13 2009 +0100
+++ b/MoinMoin/events/__init__.py	Sun Nov 15 10:23:51 2009 +0100
@@ -165,6 +165,7 @@
         Event.__init__(self, request)
         self.jid = jid
 
+
 class JabberIDUnsetEvent(Event):
     """ Sent when Jabber ID is no longer used
 
@@ -176,6 +177,7 @@
         Event.__init__(self, request)
         self.jid = jid
 
+
 class UserCreatedEvent(Event):
     """ Sent when a new user has been created """
 
@@ -187,12 +189,11 @@
         Event.__init__(self, request)
         self.user = user
 
+
 class PagePreSaveEvent(Event):
     """ Event sent when a page is about to be saved
 
-    This can be used to abort a save, for instance,
-    if handler returns
-
+    This can be used to abort a save, for instance, if handler returns Abort.
     """
 
     name = u"PagePreSaveEvent"
@@ -207,6 +208,7 @@
     """ This is a base class for messages passed from event handlers """
     pass
 
+
 class Abort(EventResult):
     """ Result returned if handler wants to abort operation that sent the event """
     def __init__(self, reason):
@@ -219,11 +221,10 @@
 def get_handlers(cfg):
     """Create a list of available event handlers.
 
-    Each handler is a handle() function defined in an plugin,
+    Each handler is a handle() function defined in a plugin,
     pretty much like in case of actions.
 
     TODO: maybe make it less dumb? ;-)
-
     """
     event_handlers = []
     names = wikiutil.getPlugins("events", cfg)
@@ -262,6 +263,7 @@
 
     return msg
 
+
 def get_subscribable_events():
     """Create and return a list of user-visible events
 
@@ -279,3 +281,4 @@
 
 # Get rid of the dummy getText so that it doesn't get imported with *
 del _
+
--- a/MoinMoin/events/emailnotify.py	Sun Nov 15 10:08:13 2009 +0100
+++ b/MoinMoin/events/emailnotify.py	Sun Nov 15 10:23:51 2009 +0100
@@ -127,7 +127,7 @@
 
 
 def handle_file_attached(event):
-    """Sends an email to super users that have subscribed to this event type"""
+    """Sends an email to users that have subscribed to this event type"""
 
     names = set()
     from_address = event.request.cfg.mail_from
@@ -163,7 +163,7 @@
 
 
 def handle_file_removed(event):
-    """Sends an email to super users that have subscribed to this event type"""
+    """Sends an email to users that have subscribed to this event type"""
 
     names = set()
     from_address = event.request.cfg.mail_from
--- a/MoinMoin/events/jabbernotify.py	Sun Nov 15 10:08:13 2009 +0100
+++ b/MoinMoin/events/jabbernotify.py	Sun Nov 15 10:23:51 2009 +0100
@@ -118,6 +118,7 @@
     notification.filter_subscriber_list(event, subscribers, True)
     return page_change("page_deleted", request, page, subscribers)
 
+
 def handle_page_renamed(event):
     """Handles event sent when a page is renamed"""
 
@@ -182,6 +183,7 @@
         if recipients:
             return notification.Success(recipients)
 
+
 def send_notification(request, jids, notification):
     """ Send notifications for a single language.
 
--- a/MoinMoin/events/notification.py	Sun Nov 15 10:08:13 2009 +0100
+++ b/MoinMoin/events/notification.py	Sun Nov 15 10:23:51 2009 +0100
@@ -12,10 +12,12 @@
 from MoinMoin import user, wikiutil
 from MoinMoin.events import EventResult
 
+
 class Result(EventResult):
     """ A base class for results of notification handlers"""
     pass
 
+
 class Failure(Result):
     """ Used to report a failure in sending notifications """
     def __init__(self, reason, recipients = None):
@@ -40,10 +42,12 @@
         """
         self.recipients = recipients
 
+
 class UnknownChangeType(Exception):
     """ Used to signal an invalid page change event """
     pass
 
+
 def page_link(request, page, querystr):
     """Create an absolute url to a given page with optional action
 
@@ -54,6 +58,7 @@
     """
     return request.getQualifiedURL(page.url(request, querystr))
 
+
 def page_change_message(msgtype, request, page, lang, **kwargs):
     """Prepare a notification text for a page change of given type
 
@@ -121,6 +126,7 @@
 
     return changes
 
+
 def user_created_message(request, _, sitename, username, email):
     """Formats a message used to notify about accounts being created
 
@@ -138,6 +144,7 @@
 
     return {'subject': subject, 'text': text}
 
+
 def attachment_added(request, _, page_name, attach_name, attach_size):
     """Formats a message used to notify about new attachments
 
@@ -232,3 +239,4 @@
                     userlist.append(usr)
 
         subscribers[lang] = userlist
+
--- a/MoinMoin/events/xapian_index.py	Sun Nov 15 10:08:13 2009 +0100
+++ b/MoinMoin/events/xapian_index.py	Sun Nov 15 10:23:51 2009 +0100
@@ -5,8 +5,10 @@
     @copyright: 2007 MoinMoin:KarolNowak
     @license: GNU GPL, see COPYING for details.
 """
+
 import MoinMoin.events as ev
 
+
 def _get_index(request):
     try:
         from MoinMoin.search.Xapian import XapianIndex
@@ -14,6 +16,7 @@
     except ImportError:
         pass
 
+
 def handle_renamed(event):
     """Updates Xapian index when a page changes its name"""
 
@@ -36,6 +39,7 @@
         if index and index.exists():
             index.update_item(event.page.page_name)
 
+
 def handle_changed(event):
     """Updates Xapian index when a page is changed"""
 
@@ -69,10 +73,10 @@
         handle_renamed(event)
     elif isinstance(event, ev.PageCopiedEvent):
         handle_copied(event)
-    elif isinstance(event, ev.PageChangedEvent) or isinstance(event, ev.TrivialPageChangedEvent):
+    elif isinstance(event, (ev.PageChangedEvent, ev.TrivialPageChangedEvent)):
         handle_changed(event)
     elif isinstance(event, ev.PageDeletedEvent):
         handle_deleted(event)
-    elif isinstance(event, ev.FileAttachedEvent) or isinstance(event, ev.FileRemovedEvent):
+    elif isinstance(event, (ev.FileAttachedEvent, ev.FileRemovedEvent)):
         handle_attachment_change(event)