def redivmod(initial_value, factors):
result = []<EOL>value = initial_value<EOL>for divisor, label in factors:<EOL><INDENT>if not divisor:<EOL><INDENT>remainder = value<EOL>if not remainder:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value, remainder = divmod(value, divisor)<EOL>if not value and not remainder:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if remainder == <NUM_LIT:1>:<EOL><INDENT>label = label[:-<NUM_LIT:1>]<EOL><DEDENT>if six.PY2:<EOL><INDENT>addition = unicode(remainder) + '<STR_LIT:U+0020>' + unicode(label)<EOL><DEDENT>else:<EOL><INDENT>addition = str(remainder) + '<STR_LIT:U+0020>' + str(label)<EOL><DEDENT>result.insert(<NUM_LIT:0>, addition)<EOL><DEDENT>if len(result) > <NUM_LIT:1>:<EOL><INDENT>result[-<NUM_LIT:1>] = "<STR_LIT>" + result[-<NUM_LIT:1>]<EOL><DEDENT>if result:<EOL><INDENT>return '<STR_LIT:U+002CU+0020>'.join(result)<EOL><DEDENT>else:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>
Chop up C{initial_value} according to the list of C{factors} and return a
formatted string.