# Path: pyxmpp/exceptions.py
# class StringprepError(Error):
#     """Exception raised when string preparation results in error."""
#     pass


import stringprep
import unicodedata
from pyxmpp.exceptions import StringprepError
        :Parameters:
            - `function`: function taking character code as input and returning
              `bool` value or the mapped for `code`."""
        self.lookup=function

class LookupTable:
    """Class for looking up RFC 3454 tables using a dictionary and/or list of ranges."""
    def __init__(self,singles,ranges):
        """Initialize `LookupTable` object.

        :Parameters:
            - `singles`: dictionary mapping Unicode characters into other Unicode characters.
            - `ranges`: list of ``((start,end),value)`` tuples mapping codes in range (start,end)
              to the value."""
        self.singles=singles
        self.ranges=ranges

    def lookup(self,c):
        """Do Unicode character lookup.

        :Parameters:
            - `c`: Unicode character to look up.

        :return: the mapped value."""
        if self.singles.has_key(c):
            return self.singles[c]
        c=ord(c)
        for (start,end),value in self.ranges:
            if c<start:
                return None

# Path: pyxmpp/exceptions.py
# class StringprepError(Error):
#     """Exception raised when string preparation results in error."""
#     pass


# Path: pyxmpp/xmppstringprep.py
import stringprep
import unicodedata
from pyxmpp.exceptions import StringprepError

        :Parameters:
            - `function`: function taking character code as input and returning
              `bool` value or the mapped for `code`."""
        self.lookup=function

class LookupTable:
    """Class for looking up RFC 3454 tables using a dictionary and/or list of ranges."""
    def __init__(self,singles,ranges):
        """Initialize `LookupTable` object.

        :Parameters:
            - `singles`: dictionary mapping Unicode characters into other Unicode characters.
            - `ranges`: list of ``((start,end),value)`` tuples mapping codes in range (start,end)
              to the value."""
        self.singles=singles
        self.ranges=ranges

    def lookup(self,c):
        """Do Unicode character lookup.

        :Parameters:
            - `c`: Unicode character to look up.

        :return: the mapped value."""
        if self.singles.has_key(c):
            return self.singles[c]
        c=ord(c)
        for (start,end),value in self.ranges:
            if c<start:
                return None

            if c<=end: