Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
monosans committed Feb 7, 2024
1 parent 9026cf9 commit 35518b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions proxy_scraper_checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import os as _os

from .typing_compat import Any as _Any

# Monkeypatch os.link to make aiofiles work on Termux
if not hasattr(_os, "link"):
from .typing_compat import Any as _Any

def _link(*args: _Any, **kwargs: _Any) -> None: # noqa: ARG001
raise RuntimeError
Expand Down
16 changes: 7 additions & 9 deletions proxy_scraper_checker/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@

from .utils import bytes_decode

HEADERS: MappingProxyType[str, str] = MappingProxyType({
hdrs.USER_AGENT: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" # noqa: E501
)
})
SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where())


class NoCharsetHeaderError(Exception):
pass


HEADERS: MappingProxyType[str, str] = MappingProxyType({
hdrs.USER_AGENT: (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" # noqa: E501
)
})
def fallback_charset_resolver(r: ClientResponse, b: bytes) -> str: # noqa: ARG001
raise NoCharsetHeaderError


@lru_cache(None)
Expand All @@ -33,7 +35,3 @@ def get_response_text(*, response: ClientResponse, content: bytes) -> str:
return content.decode(response.get_encoding())
except (NoCharsetHeaderError, UnicodeDecodeError):
return bytes_decode(content)


def fallback_charset_resolver(r: ClientResponse, b: bytes) -> str: # noqa: ARG001
raise NoCharsetHeaderError

0 comments on commit 35518b6

Please sign in to comment.