def http_statuscode_role(name, rawtext, text, lineno, inliner,
                         options={}, content=[]):
    if text.isdigit():
        code = int(text)
        try:
            status = HTTP_STATUS_CODES[code]
        except KeyError:
            msg = inliner.reporter.error('%d is invalid HTTP status code'
                                         % code, lineno=lineno)
            prb = inliner.problematic(rawtext, rawtext, msg)
            return [prb], [msg]
    else:
        try:
            code, status = re.split(r'\s', text.strip(), 1)
            code = int(code)
        except ValueError:
            msg = inliner.reporter.error(
                'HTTP status code must be an integer (e.g. `200`) or '
                'start with an integer (e.g. `200 OK`); %r is invalid' %
                text,
                line=lineno
            )
            prb = inliner.problematic(rawtext, rawtext, msg)
            return [prb], [msg]
    nodes.reference(rawtext)
    if code == 226:
        url = 'http://www.ietf.org/rfc/rfc3229.txt'
    if code == 418:
        url = 'http://www.ietf.org/rfc/rfc2324.txt'
    if code == 449:
        url = 'http://msdn.microsoft.com/en-us/library' \
              '/dd891478(v=prot.10).aspx'
    elif code in HTTP_STATUS_CODES:
        url = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html' \
              '#sec10.' + ('%d.%d' % (code // 100, 1 + code % 100))
    else:
        url = ''
    set_classes(options)
    node = nodes.reference(rawtext, '%d %s' % (code, status),
                           refuri=url, **options)
    return [node], []
dataset/ETHPy150Open saltstack/salt/doc/_ext/httpdomain.py/http_statuscode_role/original