def deconstruct(name):
    '''Deconstruct a queue-name to a set of arguments'''
    name = coerce_unicode(name, _c.FSQ_CHARSET)
    new_arg = sep = u''
    args = []
    # can't get delimiter, if string is empty
    if 1 > len(name):
        raise FSQMalformedEntryError(errno.EINVAL, u'cannot derive delimiter'\
                                     u'from: {0}'.format(name))

    delimiter, encodeseq = delimiter_encodeseq(name[0], _c.FSQ_ENCODE,
                                               _c.FSQ_CHARSET)
    # edge case, no args
    if 1 == len(name):
        return delimiter, args

    # normal case
    encoding_trg = sep
    for c in name[1:]:
        if 3 == len(encoding_trg):
            encoding_trg = sep
        if c == encodeseq or len(encoding_trg):
            encoding_trg = sep.join([encoding_trg, c])
        elif c == delimiter:
            # at delimiter, append and reset working arg
            args.append(decode(new_arg, delimiter=delimiter,
                               encodeseq=encodeseq))
            new_arg = sep
            continue

        new_arg = sep.join([new_arg, c])

    # append our last arg
    args.append(decode(new_arg, delimiter=delimiter, encodeseq=encodeseq))
    return delimiter, args
def deconstruct ( name ) : name = coerce_unicode ( name , _c . FSQ_CHARSET ) new_arg = sep = u'' args = [ ] if 1 > len ( name ) : raise FSQMalformedEntryError ( errno . EINVAL , u'cannot derive delimiter' u'from: {0}' . format ( name ) ) delimiter , encodeseq = delimiter_encodeseq ( name [ 0 ] , _c . FSQ_ENCODE , _c . FSQ_CHARSET ) if 1 == len ( name ) : return delimiter , args encoding_trg = sep for c in name [ 1 : ] : if 3 == len ( encoding_trg ) : encoding_trg = sep if c == encodeseq or len ( encoding_trg ) : encoding_trg = sep . join ( [ encoding_trg , c ] ) elif c == delimiter : args . append ( decode ( new_arg , delimiter = delimiter , encodeseq = encodeseq ) ) new_arg = sep continue new_arg = sep . join ( [ new_arg , c ] ) args . append ( decode ( new_arg , delimiter = delimiter , encodeseq = encodeseq ) ) return delimiter , args
Deconstruct a queue-name to a set of arguments