<commit_before>"""
    sphinxcontrib.httpdomain
    ~~~~~~~~~~~~~~~~~~~~~~~~

    The HTTP domain for documenting RESTful HTTP APIs.

    :copyright: Copyright 2011 by <NAME>
    :license: BSD, see LICENSE for details.

"""

import os
import json
import re

from docutils import nodes
from docutils.parsers.rst.roles import set_classes

from pygments.lexer import RegexLexer, bygroups
from pygments.lexers import get_lexer_by_name
from pygments.token import Literal, Text,  Operator, Keyword, Name, Number
from pygments.util import ClassNotFound

from sphinx import addnodes
from sphinx.roles import XRefRole
from sphinx.domains import Domain, ObjType, Index
from sphinx.directives import ObjectDescription
from sphinx.util.nodes import make_refnode
from sphinx.util.docfields import GroupedField, TypedField


class DocRef(object):
    """Represents a link to an RFC which defines an HTTP method."""

    def __init__(self, base_url, anchor, section):
        """Stores the specified attributes which represent a URL which links to
        an RFC which defines an HTTP method.

        """
        self.base_url = base_url
        self.anchor = anchor
        self.section = section

    def __repr__(self):
        """Returns the URL which this object represents, which points to the
        location of the RFC which defines some HTTP method.

        """
        return '{}#{}{}'.format(self.base_url, self.anchor, self.section)


class RFC2616Ref(DocRef):

    def __init__(self, section):
        url = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec{0:d}.html'
        url = url.format(int(section))
        super(RFC2616Ref, self).__init__(url, 'sec', section)


class IETFRef(DocRef):

    def __init__(self, rfc, section):
        url = 'http://tools.ietf.org/html/rfc{0:d}'.format(rfc)
        super(IETFRef, self).__init__(url, 'section-', section)
        

class EventSourceRef(DocRef):

    def __init__(self, section):
        url = 'http://www.w3.org/TR/eventsource/'
        super(EventSourceRef, self).__init__(url, section, '')


#: Mapping from lowercase HTTP method name to :class:`DocRef` object which
#: maintains the URL which points to the section of the RFC which defines that
#: HTTP method.
METHOD_REFS = {
    'patch': IETFRef(5789, 2),
    'options': RFC2616Ref(9.2),
    'get': RFC2616Ref(9.3),
    'head': RFC2616Ref(9.4),
    'post': RFC2616Ref(9.5),
    'put': RFC2616Ref(9.6),
    'delete': RFC2616Ref(9.7),
    'trace': RFC2616Ref(9.8),
    'connect': RFC2616Ref(9.9),
    'copy': IETFRef(2518, 8.8),
    'any': ''
}

#: Mapping from HTTP header name to :class:`DocRef` object which
#: maintains the URL which points to the related section of the RFC.
HEADER_REFS = {
    'Accept': RFC2616Ref(14.1),<commit_msg>Fix httpdomain compatibility issue with Python 2.6<commit_after>"""
    sphinxcontrib.httpdomain
    ~~~~~~~~~~~~~~~~~~~~~~~~

    The HTTP domain for documenting RESTful HTTP APIs.

    :copyright: Copyright 2011 by <NAME>
    :license: BSD, see LICENSE for details.

"""

import os
import json
import re

from docutils import nodes
from docutils.parsers.rst.roles import set_classes

from pygments.lexer import RegexLexer, bygroups
from pygments.lexers import get_lexer_by_name
from pygments.token import Literal, Text,  Operator, Keyword, Name, Number
from pygments.util import ClassNotFound

from sphinx import addnodes
from sphinx.roles import XRefRole
from sphinx.domains import Domain, ObjType, Index
from sphinx.directives import ObjectDescription
from sphinx.util.nodes import make_refnode
from sphinx.util.docfields import GroupedField, TypedField


class DocRef(object):
    """Represents a link to an RFC which defines an HTTP method."""

    def __init__(self, base_url, anchor, section):
        """Stores the specified attributes which represent a URL which links to
        an RFC which defines an HTTP method.

        """
        self.base_url = base_url
        self.anchor = anchor
        self.section = section

    def __repr__(self):
        """Returns the URL which this object represents, which points to the
        location of the RFC which defines some HTTP method.

        """
        return '{0}#{1}{2}'.format(self.base_url, self.anchor, self.section)


class RFC2616Ref(DocRef):

    def __init__(self, section):
        url = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec{0:d}.html'
        url = url.format(int(section))
        super(RFC2616Ref, self).__init__(url, 'sec', section)


class IETFRef(DocRef):

    def __init__(self, rfc, section):
        url = 'http://tools.ietf.org/html/rfc{0:d}'.format(rfc)
        super(IETFRef, self).__init__(url, 'section-', section)


class EventSourceRef(DocRef):

    def __init__(self, section):
        url = 'http://www.w3.org/TR/eventsource/'
        super(EventSourceRef, self).__init__(url, section, '')


#: Mapping from lowercase HTTP method name to :class:`DocRef` object which
#: maintains the URL which points to the section of the RFC which defines that
#: HTTP method.
METHOD_REFS = {
    'patch': IETFRef(5789, 2),
    'options': RFC2616Ref(9.2),
    'get': RFC2616Ref(9.3),
    'head': RFC2616Ref(9.4),
    'post': RFC2616Ref(9.5),
    'put': RFC2616Ref(9.6),
    'delete': RFC2616Ref(9.7),
    'trace': RFC2616Ref(9.8),
    'connect': RFC2616Ref(9.9),
    'copy': IETFRef(2518, 8.8),
    'any': ''
}

#: Mapping from HTTP header name to :class:`DocRef` object which
#: maintains the URL which points to the related section of the RFC.
HEADER_REFS = {
    'Accept': RFC2616Ref(14.1),
{'fraction_non_alphanumeric': 0.12061482820976492, 'fraction_numerical': 0.03345388788426763, 'mean_word_length': 3.5187908496732025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '608958', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1739, 'n_words': 527}