def versioncmp(v1, v2):
def normalize(v):<EOL><INDENT>"""<STR_LIT>"""<EOL>return [int(x) for x in re.sub(r'<STR_LIT>', '<STR_LIT>', v).split("<STR_LIT:.>")]<EOL><DEDENT>try:<EOL><INDENT>return cmp(normalize(v1), normalize(v2))<EOL><DEDENT>except NameError:<EOL><INDENT>return (normalize(v1) > normalize(v2)) - (<EOL>normalize(v1) < normalize(v2))<EOL><DEDENT>
Compares two objects, x and y, and returns an integer according to the
    outcome. The return value is negative if x < y, zero if x == y and
    positive if x > y.

    :param v1: The first object to compare.
    :param v2: The second object to compare.

    :returns: -1, 0 or 1.
    :rtype: :obj:`int`