Skip to content

Commit

Permalink
spacing OCD
Browse files Browse the repository at this point in the history
  • Loading branch information
meeb committed Jul 27, 2024
1 parent 2a137a3 commit d6aea5c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from pathlib import Path
from ipaddress import IPv4Network, IPv4Address, IPv6Network, IPv6Address

import whoisit


Expand Down
2 changes: 2 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from pathlib import Path
from datetime import datetime
from ipaddress import IPv4Network, IPv6Network

from dateutil.tz import tzoffset, tzutc

import whoisit


Expand Down
1 change: 1 addition & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
from pathlib import Path
from ipaddress import IPv4Network, IPv4Address, IPv6Network, IPv6Address

import whoisit


Expand Down
1 change: 1 addition & 0 deletions tools/list_public_tlds_with_rdap_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


import requests

import whoisit
from whoisit.logger import get_logger
from whoisit.errors import UnsupportedError
Expand Down
4 changes: 4 additions & 0 deletions whoisit/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
is_subnet_of,
)


log = get_logger('bootstrap')


Expand Down Expand Up @@ -417,6 +418,7 @@ def get_rir_name_by_endpoint_url(self, url):


class Bootstrap(BaseBootstrap):

def __init__(self, session=None, allow_insecure_ssl=False, do_super_init=True):
if do_super_init:
BaseBootstrap.__init__(self)
Expand All @@ -430,6 +432,7 @@ def bootstrap(self, overrides=False, allow_insecure=False):


class BootstrapAsync(BaseBootstrap):

def __init__(self, client=None, allow_insecure_ssl=False, do_super_init=True):
if do_super_init:
BaseBootstrap.__init__(self)
Expand All @@ -443,6 +446,7 @@ async def bootstrap_async(self, overrides=False, allow_insecure=False):


class _BootstrapMainModule(Bootstrap, BootstrapAsync):

def __init__(self) -> None:
Bootstrap.__init__(self, do_super_init=True)
BootstrapAsync.__init__(self, do_super_init=False)
3 changes: 3 additions & 0 deletions whoisit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
)
from typing import Optional
from typing_extensions import TypedDict

from dateutil.parser import parse as dateutil_parse

from .errors import BootstrapError, ParseError
from .logger import get_logger


log = get_logger('parser')


Expand Down
5 changes: 4 additions & 1 deletion whoisit/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .logger import get_logger
from .utils import contains_only_chars, http_request, http_request_async


log = get_logger('query')


Expand Down Expand Up @@ -221,6 +222,7 @@ def _process_response(self, response):
except (TypeError, ValueError) as e:
raise QueryError(f'Failed to parse RDAP Query response as JSON: {e}') from e


class Query(BaseQuery):
"""
Make an HTTP request to an RDAP endpoint as a query. This is slightly more
Expand All @@ -237,9 +239,10 @@ def request(self, *args, **kwargs):
response = http_request(self.session, url=self.url, method=self.method, *args, **kwargs)
return self._process_response(response)


class QueryAsync(BaseQuery):
"""
Make an Async HTTP request to an RDAP endpoint as a query. This is slightly more
Make an async HTTP request to an RDAP endpoint as a query. This is slightly more
elaborate than a single function just to allow kwargs to be arbitrarily passed
to both requests and the requested URL if required.
"""
Expand Down
2 changes: 2 additions & 0 deletions whoisit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .logger import get_logger
from .version import version


log = get_logger('utils')
user_agent = 'whoisit/{version}'
insecure_ssl_ciphers = 'ALL:@SECLEVEL=1'
Expand Down Expand Up @@ -88,6 +89,7 @@ def create_session(allow_insecure_ssl=False):
session.mount('https://', InsecureSSLAdapter())
return session


def create_async_client(allow_insecure_ssl=False):
limits = httpx.Limits(max_connections=async_http_max_connections, max_keepalive_connections=async_max_keepalive_connections)
retries = httpx.AsyncHTTPTransport(retries=http_max_retries, limits=limits)
Expand Down

0 comments on commit d6aea5c

Please sign in to comment.