From 8f678c341f298dc3b5b3e08ef346295e765c6403 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 11 Mar 2024 20:41:04 +0100 Subject: [PATCH] Version --- requests_util/__init__.py | 12 ++++++++---- requests_util/_version.py | 1 + setup.py | 8 +++++--- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 requests_util/_version.py diff --git a/requests_util/__init__.py b/requests_util/__init__.py index e92f09f..087f8cd 100644 --- a/requests_util/__init__.py +++ b/requests_util/__init__.py @@ -1,4 +1,6 @@ -'''Utility module for setting up ratelimiting on third-party sessions.''' +"""Utility module for setting up ratelimiting on third-party sessions.""" + +from _version import __version__ import logging @@ -13,13 +15,15 @@ except ImportError: ) -def setup_limiter(session: requests.Session, url_prefix: str, **limiter_args): requests.Session: - ''' +def setup_limiter( + session: requests.Session, url_prefix: str, **limiter_args +) -> requests.Session: + """ Initializes limiter on session for the given domain with the given settings. Will always return the given session itself. - ''' + """ if requests_ratelimiter: session.mount(url_prefix, requests_ratelimiter.LimiterAdapter(**limiter_args)) return session diff --git a/requests_util/_version.py b/requests_util/_version.py new file mode 100644 index 0000000..b794fd4 --- /dev/null +++ b/requests_util/_version.py @@ -0,0 +1 @@ +__version__ = '0.1.0' diff --git a/setup.py b/setup.py index 72a8231..a950dd9 100644 --- a/setup.py +++ b/setup.py @@ -7,18 +7,20 @@ PACKAGE_NAME = 'requests_util' with open('README.md', 'r') as f: readme = f.read() -with open(PACKAGE_NAME+'/_version.py', 'r') as f: +with open(PACKAGE_NAME + '/_version.py', 'r') as f: text = f.read() match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text) version = match.group(2) del match, text + def get_short_description(readme: str): readme = re.sub(r'#+[^\n]*\n+', '', readme) m = re.search(r'^\s*(\w+[\w\s,]+\.)', readme) readme = m.group(1) return readme + setup( name=PACKAGE_NAME, version=version, @@ -27,10 +29,10 @@ setup( long_description_content_type='text/markdown', author='Jmaa', author_email='jonjmaa@gmail.com', - url='https://gitfub.space/Jmaa/'+PACKAGE_NAME, + url='https://gitfub.space/Jmaa/' + PACKAGE_NAME, packages=[PACKAGE_NAME], install_requires=['requests'], - extras_require = { + extras_require={ 'Request ratelimiting': ['requests_ratelimiter'], 'Request caching': ['requests_cache'], },