def generate_search_string(applicant_name, year=None, country='EP'):
    """ Return cql search string given a name string and year. """
    search_string = 'pa="{0}"'.format(applicant_name)
    if country:
        search_string = ' and '.join([search_string, 'pn={0}'.format(country)])
    if year:
        search_string = ' and '.join([search_string, 'pd within {0}'.format
            (year)])
    return search_string
