示例#1
0
    def getNotificationFactoryNameForChannel(self,channel,domain=None):
        '''
        This method returns the name of the notification service for the channel
        or domain from the configuration information given in the CDB.

        Parameters:
        - channel is the channel name of the desired factory
        - domain is the domain of the desired factory

        Returns: string containing the factory name or None

        Raises: Nothing
        '''
        temp=""
        if channel is not None:
            crec = [ chan for chan in get_notification_service_mapping('Channel') if wildcharMatch(chan['Name'], channel)]
            if crec != []:
                temp=crec[0]['NotificationService']

        if len(temp)==0 and (domain is not None):
            crec = [ chan for chan in get_notification_service_mapping('Domain') if wildcharMatch(chan['Name'], domain)]
            if crec != []:
                temp=crec[0]['NotificationService']

        if len(temp)==0:
            crec = get_notification_service_mapping('Default')
            if crec != []:
                temp=crec[0]['DefaultNotificationService']
            else:
                return None
            
        if not temp.endswith(acscommon.NOTIFICATION_FACTORY_NAME):
            return temp+acscommon.NOTIFICATION_FACTORY_NAME
        else:
            return temp
示例#2
0
    def getNotificationFactoryNameForChannel(self,channel,domain=None):
        '''
        This method returns the name of the notification service for the channel
        or domain from the configuration information given in the CDB.

        Parameters:
        - channel is the channel name of the desired factory
        - domain is the domain of the desired factory

        Returns: string containing the factory name or None

        Raises: Nothing
        '''

        if channel is not None:
            crec = [ chan for chan in get_notification_service_mapping('Channel') if wildcharMatch(chan['Name'], channel)]
            if crec != []:
                return crec[0]['NotificationService']

        if domain is not None:
            crec = [ chan for chan in get_notification_service_mapping('Domain') if wildcharMatch(chan['Name'], domain)]
            if crec != []:
                return crec[0]['NotificationService']

        crec = get_notification_service_mapping('Default')
        if crec != []:
            return crec[0]['DefaultNotificationService']
        else:
            return None
示例#3
0
    def getNotificationFactoryNameForChannel(self, channel, domain=None):
        '''
        This method returns the name of the notification service for the channel
        or domain from the configuration information given in the CDB.

        Parameters:
        - channel is the channel name of the desired factory
        - domain is the domain of the desired factory

        Returns: string containing the factory name or None

        Raises: Nothing
        '''
        temp = ""
        if channel is not None:
            crec = [
                chan for chan in get_notification_service_mapping('Channel')
                if wildcharMatch(chan['Name'], channel)
            ]
            if crec != []:
                temp = crec[0]['NotificationService']

        if len(temp) == 0 and (domain is not None):
            crec = [
                chan for chan in get_notification_service_mapping('Domain')
                if wildcharMatch(chan['Name'], domain)
            ]
            if crec != []:
                temp = crec[0]['NotificationService']

        if len(temp) == 0:
            crec = get_notification_service_mapping('Default')
            if crec != []:
                temp = crec[0]['DefaultNotificationService']
            else:
                return None

        if not temp.endswith(acscommon.NOTIFICATION_FACTORY_NAME):
            return temp + acscommon.NOTIFICATION_FACTORY_NAME
        else:
            return temp
# "@(#) $Id: acsutilpyTestWildcharMatcher.py,v 1.1 2012/01/25 13:46:30 acaproni Exp $"
#
# who       when      what
# --------  --------  ----------------------------------------------
# acaproni  2012-01-25  created
#

'''
Test WildcharMatchr
'''

from AcsutilPy.WildcharMatcher import simpleWildcardToRegex
from AcsutilPy.WildcharMatcher import wildcharMatch

if __name__ == "__main__":
    # Test simpleWildcardToRegex
    print "Translation to regex",simpleWildcardToRegex("No control chars in wildcard")
    print "Translation to regex",simpleWildcardToRegex("Dot.and asterisk*")
    print "Translation to regex",simpleWildcardToRegex("Asterisk* and 2 ?questions?marks")
    print "Translation to regex",simpleWildcardToRegex("Regexp control chars {} . () $^ [] \\ |")
    
    # Test wildcharMatch
    print "Match with '*' (expect True)",wildcharMatch("*", "Match")
    print "Match with '?' (expect True)", wildcharMatch("?est",'Test')
    print "Match with regex control char' (expect True)", wildcharMatch("?rray[4]",'Array[4]')
    print "Does not match with '?' (expect False)", wildcharMatch("?est",'finest')
    print "Does not match with '*' (expect False)", wildcharMatch("*pute",'Computer')
    print "Does not match with '*' and ?' (expect False)", wildcharMatch("?est* day",'Yesterday')
#
# ___oOo___
示例#5
0
'''
Test WildcharMatchr
'''

from AcsutilPy.WildcharMatcher import simpleWildcardToRegex
from AcsutilPy.WildcharMatcher import wildcharMatch

if __name__ == "__main__":
    # Test simpleWildcardToRegex
    print "Translation to regex", simpleWildcardToRegex(
        "No control chars in wildcard")
    print "Translation to regex", simpleWildcardToRegex("Dot.and asterisk*")
    print "Translation to regex", simpleWildcardToRegex(
        "Asterisk* and 2 ?questions?marks")
    print "Translation to regex", simpleWildcardToRegex(
        "Regexp control chars {} . () $^ [] \\ |")

    # Test wildcharMatch
    print "Match with '*' (expect True)", wildcharMatch("*", "Match")
    print "Match with '?' (expect True)", wildcharMatch("?est", 'Test')
    print "Match with regex control char' (expect True)", wildcharMatch(
        "?rray[4]", 'Array[4]')
    print "Does not match with '?' (expect False)", wildcharMatch(
        "?est", 'finest')
    print "Does not match with '*' (expect False)", wildcharMatch(
        "*pute", 'Computer')
    print "Does not match with '*' and ?' (expect False)", wildcharMatch(
        "?est* day", 'Yesterday')
#
# ___oOo___