Compare commits
4 Commits
4a9a084bc5
...
136d19d813
Author | SHA1 | Date | |
---|---|---|---|
136d19d813 | |||
dbfcc8e579 | |||
c2b32c9ea2 | |||
4367d95745 |
|
@ -1,4 +1,8 @@
|
||||||
# Requests utilities
|
<!--- WARNING ---!>
|
||||||
|
<!--- THIS IS AN AUTO-GENERATED FILE ---!>
|
||||||
|
<!--- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN ---!>
|
||||||
|
|
||||||
|
# Requests utilities.
|
||||||
|
|
||||||
Utility for standarized usage of HTTP requests extension libraries in a modular fashion across different libraries.
|
Utility for standarized usage of HTTP requests extension libraries in a modular fashion across different libraries.
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
"""Utility module for setting up ratelimiting on third-party sessions."""
|
"""# Requests utilities.
|
||||||
|
|
||||||
|
Utility for standarized usage of HTTP requests extension libraries in a modular fashion across different libraries.
|
||||||
|
|
||||||
|
Currently supports [`requests_cache`](https://requests-cache.readthedocs.io) and [`requests_ratelimiter`](https://github.com/JWCook/requests-ratelimiter).
|
||||||
|
|
||||||
|
The intention is that a libraries can automatically setup ratelimiting for
|
||||||
|
their specific use cases, as the library most likely has a better
|
||||||
|
understanding of the ratelimiting and caching behaviour of their associated websites than the user has.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
import pathlib
|
|
||||||
import os
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -33,8 +42,7 @@ CACHE_PATH_FROM_HOME = '.local/share/usagi-keiretsu/fin_data/http_cache'
|
||||||
|
|
||||||
|
|
||||||
def initialize_session() -> requests.Session:
|
def initialize_session() -> requests.Session:
|
||||||
"""
|
"""Creates Session with or without caching depending upon current
|
||||||
Creates Session with or without caching depending upon current
|
|
||||||
capabilities.
|
capabilities.
|
||||||
"""
|
"""
|
||||||
logger.info('Setting up session')
|
logger.info('Setting up session')
|
||||||
|
@ -64,8 +72,7 @@ def setup_limiter(
|
||||||
expire_after: datetime.datetime | None = None,
|
expire_after: datetime.datetime | None = None,
|
||||||
**limiter_args,
|
**limiter_args,
|
||||||
) -> requests.Session:
|
) -> requests.Session:
|
||||||
"""
|
"""Initializes limiter on session for the given domain with the given
|
||||||
Initializes limiter on session for the given domain with the given
|
|
||||||
settings.
|
settings.
|
||||||
|
|
||||||
Will always return the given session itself.
|
Will always return the given session itself.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.10'
|
__version__ = '0.1.11'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user