replace httpx with the requests stdlib

This commit is contained in:
gwen 2024-10-16 13:24:14 +02:00
parent 0ce1550028
commit 19ecc56316

View file

@ -7,7 +7,7 @@ from sphinx.util.docutils import SphinxDirective, SphinxRole
from sphinx.util.typing import ExtensionMetadata from sphinx.util.typing import ExtensionMetadata
from sphinx.directives.code import LiteralInclude, container_wrapper from sphinx.directives.code import LiteralInclude, container_wrapper
from httpx import get import requests
class ExtInclude(LiteralInclude): class ExtInclude(LiteralInclude):
"""A directive to include code that comes from an url """A directive to include code that comes from an url
@ -29,9 +29,13 @@ class ExtInclude(LiteralInclude):
def run(self) -> list[nodes.Node]: def run(self) -> list[nodes.Node]:
url = self.arguments[0] url = self.arguments[0]
content = get(url) headers = {
'accept': 'application/text',
'Content-Type': 'application/text',
}
response = requests.get(url, headers=headers)
#paragraph_node = nodes.paragraph(text=f'hello {self.arguments[0]}!') #paragraph_node = nodes.paragraph(text=f'hello {self.arguments[0]}!')
code = content.text code = response.text
literal = nodes.literal_block(code, code) literal = nodes.literal_block(code, code)
if 'language' in self.options: if 'language' in self.options: