def METHOD_NAME(version):
    try:
        if version.count(".") in (1, 2):
            if int(version.split(".")[0]) > 4:
                if version.endswith(".*"):
                    return GlobVersion(version)
                return PostModernMozillaVersion(version)
            else:
                return ModernMozillaVersion(version)
        else:
            return AncientMozillaVersion(version)
    except ValueError:
        raise BadDataError("Version number %s is invalid." % version)