Skip to content

Commit

Permalink
Test printing reason
Browse files Browse the repository at this point in the history
  • Loading branch information
sciencewhiz committed Nov 20, 2024
1 parent b6a93be commit 042bfe9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions source/_extensions/_remoteliteralinclude.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
import requests
import sys
import warnings

from difflib import unified_diff

from docutils import nodes
from docutils.parsers.rst import directives
from docutils.statemachine import ViewList
from six import text_type

from importlib import metadata

from sphinx import addnodes
from sphinx.locale import __
from sphinx.util import logging
Expand Down Expand Up @@ -49,6 +52,9 @@ def __init__(self, url, options, config):

self.parse_options()

print("User-Agent: sphinxext-remoteliteralinclude/" + metadata.version.__str__)
__version__ = metadata.version.__str__

def parse_options(self):
# type: () -> None
for option1, option2 in self.INVALID_OPTIONS_PAIR:
Expand All @@ -62,13 +68,15 @@ def read_file(self, url, location=None):
# try:
# with codecs.open(url, 'r', self.encoding, errors='strict') as f: # type: ignore # NOQA
# text = f.read() # type: unicode
response = requests.get(url, headers = {'User-Agent': 'sphinxext-remoteliteralinclude'})
response = requests.get(
url#, headers={"User-Agent": "sphinxext-remoteliteralinclude"}
)
text = response.text

if text:
if not response.status_code == requests.codes.ok:
raise ValueError(
"HTTP request returned error code %s" % response.status_code
"HTTP request returned error code %s, %s" % (response.status_code, response.reason)
)

if "tab-width" in self.options:
Expand Down
2 changes: 1 addition & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"sphinxext.opengraph",
"sphinxext.photofinish",
"sphinxext.rediraffe",
#"sphinxext.remoteliteralinclude",
# "sphinxext.remoteliteralinclude",
"sphinxext.toptranslators",
"sphinxext.mimictoc",
"sphinxext.presentations",
Expand Down

0 comments on commit 042bfe9

Please sign in to comment.