ckan/include/rjsmin.py
def fix_charclass(result):
        """ Fixup string of chars to fit into a regex char class """
        pos = result.find('-')
        if pos >= 0:
            result = r'%s%s-' % (result[:pos], result[pos + 1:])

        def sequentize(string):
            """
            Notate consecutive characters as sequence

            (1-4 instead of 1234)
            """
            first, last, result = None, None, []
            for char in map(ord, string):
                if last is None:
                    first = last = char
                elif last + 1 == char:
                    last = char
                else:
                    result.append((first, last))
                    first = last = char
            if last is not None:
                result.append((first, last))
            return ''.join(['%s%s%s' % (
                chr(first),
                last > first + 1 and '-' or '',
                last != first and chr(last) or ''
            ) for first, last in result])

        return _re.sub(r'([\000-\040\047])', # for better portability
            lambda m: '\\%03o' % ord(m.group(1)), (sequentize(result)
                .replace('\\', '\\\\')
                .replace('[', '\\[')
                .replace(']', '\\]')
            )
        )
 Fixup string of chars to fit into a regex char class 
Fixup string of chars to fit into a regex char class
Fixup string of chars to fit into a regex char class
def fix_charclass(result):
        pos = result.find('-')
        if pos >= 0:
            result = r'%s%s-' % (result[:pos], result[pos + 1:])
        def sequentize(string):
            first, last, result = None, None, []
            for char in map(ord, string):
                if last is None:
                    first = last = char
                elif last + 1 == char:
                    last = char
                else:
                    result.append((first, last))
                    first = last = char
            if last is not None:
                result.append((first, last))
            return ''.join(['%s%s%s' % (
                chr(first),
                last > first + 1 and '-' or '',
                last != first and chr(last) or ''
            ) for first, last in result])
        return _re.sub(r'([\000-\040\047])', 
            lambda m: '\\%03o' % ord(m.group(1)), (sequentize(result)
                .replace('\\', '\\\\')
                .replace('[', '\\[')
                .replace(']', '\\]')
            )
        )
def fix_charclass ( result ) : pos = result . find ( '-' ) if pos >= 0 : result = r'%s%s-' % ( result [ : pos ] , result [ pos + 1 : ] ) def sequentize ( string ) : """
            Notate consecutive characters as sequence

            (1-4 instead of 1234)
            """ first , last , result = None , None , [ ] for char in map ( ord , string ) : if last is None : first = last = char elif last + 1 == char : last = char else : result . append ( ( first , last ) ) first = last = char if last is not None : result . append ( ( first , last ) ) return '' . join ( [ '%s%s%s' % ( chr ( first ) , last > first + 1 and '-' or '' , last != first and chr ( last ) or '' ) for first , last in result ] ) return _re . sub ( r'([\000-\040\047])' , lambda m : '\\%03o' % ord ( m . group ( 1 ) ) , ( sequentize ( result ) . replace ( '\\' , '\\\\' ) . replace ( '[' , '\\[' ) . replace ( ']' , '\\]' ) ) )
Fixup string of chars to fit into a regex char class
Fixup string of chars to fit into a regex char class
""" Fixup string of chars to fit into a regex char class """ """
            Notate consecutive characters as sequence

            (1-4 instead of 1234)
            """ # for better portability
result