Implement pep8 'ignore_code' hook.

def putty_ignore_code(options, code):
    """Implement pep8 'ignore_code' hook."""
    reporter, line_number, offset, text, check = get_reporter_state()
    try:
        line = reporter.lines[line_number - 1]
    except IndexError:
        line = ''

    options.ignore = options._orig_ignore
    options.select = options._orig_select

    for rule in options.putty_ignore:
        if rule.match(reporter.filename, line, list(reporter.counters) + [code]):
            if rule._append_codes:
                options.ignore = options.ignore + rule.codes
            else:
                options.ignore = rule.codes

    for rule in options.putty_select:
        if rule.match(reporter.filename, line, list(reporter.counters) + [code]):
            if rule._append_codes:
                options.select = options.select + rule.codes
            else:
                options.select = rule.codes

    return ignore_code(options, code)