import logging


def format_year(year):
    """
    Formats year text data from automart. Returns int.
    """
    if year is None:
        return year
    try:
        return int(year)
    except (ValueError, TypeError):
        logging.warning("Could not convert year data to int: %r" % year)
        return year