def try_parse_int(s, default_value=None):
    """Parse an integer or return a default value if it cannot be done or the string is None."""
    try:
        return int(s) if s is not None else default_value
    except ValueError:
        return default_value