"""
Forward notification

This is a simple forwarder bridge

Config Example:
[regrowl.bridge.forward]
host = 127.0.0.1
pass = p@ssword
"""

from __future__ import absolute_import

import logging

from gntp.notifier import GrowlNotifier
from regrowl.regrowler import ReGrowler
from regrowl.config import DEFAULTS

logger = logging.getLogger(__name__)

# Ignore debug logging from lower level growl library
logging.getLogger('gntp.notifier').setLevel(logging.INFO)

__all__ = ['ForwardNotifier']


class ForwardNotifier(ReGrowler):
    valid = ['REGISTER', 'NOTIFY']

    def forward(self, messagetype, packet):
        self.password = self.get('pass')
        self.passwordHash = self.get('passwordHash', DEFAULTS['passwordHash'])
        self.host = self.get('host')
        self.port = self.getint('port', DEFAULTS['port'])

        packet.set_password(self.password, self.passwordHash)

        logger.info('Forwarding %s to %s:%s', messagetype, self.host, self.port)

        self.growler = GrowlNotifier(
            hostname=self.host,
            port=self.port,
        )._send(messagetype, packet)

    def register(self, packet):
        self.forward('REGISTER', packet)

    def notify(self, packet):
        self.forward('NOTIFY', packet)

@@ -99,34 +99,50 @@
 rd%5D%0A
-host = 127.0.0.1%0Apass = p@
+label = host,password%0Aother = host:port,pa
 sswo
@@ -596,16 +596,33 @@
 rd(self,
+ packet):%0A       
  message
@@ -629,81 +629,124 @@
 type
-,
+ =
  packet
-):%0A        self.password = self.get('pass')%0A        self.
+.info%5B'messagetype'%5D%0A        for label, settings in self.config.items(__name__):%0A            dest, 
 password
 Hash
@@ -745,140 +745,226 @@
 word
-Hash
  = se
-lf.get('passwordHash', DEFAULTS%5B'passwordHash'%5D)%0A        self.host = self.get('host')%0A        self.port = self.getint('port
+ttings.split(',')%0A            try:%0A                host, port = dest.split(':')%0A            except ValueError:%0A                host, port = dest, DEFAULTS%5B'port'%5D%0A%0A            passwordHash = self.get('passwordHash
 ', D
@@ -977,16 +977,28 @@
 S%5B'p
-ort
+asswordHash
 '%5D)%0A%0A
+    
     
@@ -1021,21 +1021,16 @@
 assword(
-self.
 password
@@ -1031,21 +1031,16 @@
 ssword, 
-self.
 password
@@ -1046,16 +1046,20 @@
 dHash)%0A%0A
+    
         
@@ -1113,24 +1113,14 @@
 pe, 
-self.
 host, 
-self.
 port
@@ -1134,22 +1134,11 @@
     
-self.growler =
+   
  Gro
@@ -1157,24 +1157,28 @@
             
+    
 hostname=sel
@@ -1178,19 +1178,18 @@
 ame=
-self.
 host,%0A
+    
     
@@ -1201,21 +1201,16 @@
    port=
-self.
 port,%0A  
@@ -1215,16 +1215,20 @@
         
+ 
+   
 )._send(
@@ -1302,28 +1302,16 @@
 forward(
-'REGISTER', 
 packet)%0A
@@ -1366,18 +1366,8 @@
 ard(
-'NOTIFY', 
 pack

Update regrowl.bridge.forward to use similar list rules as regrowl.bridge.push