# Path: routes/util.py
# def _url_quote(string, encoding):
#     """A Unicode handling version of urllib.quote."""
#     if encoding:
#         if isinstance(string, unicode):
#             s = string.encode(encoding)
#         elif isinstance(string, str):
#             # assume the encoding is already correct
#             s = string
#         else:
#             s = unicode(string).encode(encoding)
#     else:
#         s = str(string)
#     return urllib.quote(s, '/')
# 
# def _str_encode(string, encoding):
#     if encoding:
#         if isinstance(string, unicode):
#             s = string.encode(encoding)
#         elif isinstance(string, str):
#             # assume the encoding is already correct
#             s = string
#         else:
#             s = unicode(string).encode(encoding)
#     else:
#         s = str(string)
#     return s


import re
import sys
import urllib
    from sets import ImmutableSet as frozenset
from routes.util import _url_quote as url_quote, _str_encode
        Note: This MUST be called before match can function properly.
        
        clist should be a list of valid controller strings that can be 
        matched, for this reason makeregexp should be called by the web
        framework after it knows all available controllers that can be
        utilized.
        
        """
        if self.minimization:
            reg = self.buildnextreg(self.routelist, clist)[0]
            if not reg:
                reg = '/'
            reg = reg + '(/)?' + '$'
        
            if not reg.startswith('/'):
                reg = '/' + reg
        else:
            reg = self.buildfullreg(clist)
        
        reg = '^' + reg
        
        self.regexp = reg
        self.regmatch = re.compile(reg)
    
    def buildfullreg(self, clist):
        """Build the regexp by iterating through the routelist and
        replacing dicts with the appropriate regexp match"""
        regparts = []
        for part in self.routelist:
            if isinstance(part, dict):

# Path: routes/util.py
# def _url_quote(string, encoding):
#     """A Unicode handling version of urllib.quote."""
#     if encoding:
#         if isinstance(string, unicode):
#             s = string.encode(encoding)
#         elif isinstance(string, str):
#             # assume the encoding is already correct
#             s = string
#         else:
#             s = unicode(string).encode(encoding)
#     else:
#         s = str(string)
#     return urllib.quote(s, '/')
# 
# def _str_encode(string, encoding):
#     if encoding:
#         if isinstance(string, unicode):
#             s = string.encode(encoding)
#         elif isinstance(string, str):
#             # assume the encoding is already correct
#             s = string
#         else:
#             s = unicode(string).encode(encoding)
#     else:
#         s = str(string)
#     return s


# Path: routes/route.py
import re
import sys
import urllib
    from sets import ImmutableSet as frozenset
from routes.util import _url_quote as url_quote, _str_encode

        Note: This MUST be called before match can function properly.
        
        clist should be a list of valid controller strings that can be 
        matched, for this reason makeregexp should be called by the web
        framework after it knows all available controllers that can be
        utilized.
        
        """
        if self.minimization:
            reg = self.buildnextreg(self.routelist, clist)[0]
            if not reg:
                reg = '/'
            reg = reg + '(/)?' + '$'
        
            if not reg.startswith('/'):
                reg = '/' + reg
        else:
            reg = self.buildfullreg(clist)
        
        reg = '^' + reg
        
        self.regexp = reg
        self.regmatch = re.compile(reg)
    
    def buildfullreg(self, clist):
        """Build the regexp by iterating through the routelist and
        replacing dicts with the appropriate regexp match"""
        regparts = []
        for part in self.routelist:
            if isinstance(part, dict):

                var = part['name']