From 515ef093e966fc4c76b84b79f525e42963f16cec Mon Sep 17 00:00:00 2001 From: Emil Vanherp Date: Thu, 11 Nov 2021 22:53:45 +0100 Subject: [PATCH 1/2] add version string to package --- pydelijn/__init__.py | 2 ++ setup.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pydelijn/__init__.py b/pydelijn/__init__.py index d2acb8d..7a3d21e 100644 --- a/pydelijn/__init__.py +++ b/pydelijn/__init__.py @@ -1,2 +1,4 @@ """Initialize the package.""" NAME = "pydelijn" + +__version__ = "0.6.1" diff --git a/setup.py b/setup.py index 5751455..f00f5b8 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,19 @@ """Setup tools config.""" +import re + import setuptools with open("README.md", "r") as fh: LONG = fh.read() +with open("pydelijn/__init__.py", "r") as fd: + version = re.search( + r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE + ).group(1) + setuptools.setup( name="pydelijn", - version="0.6.1", + version=version, author="bollewolle", author_email="dev@bollewolle.be", python_requires=">=3.5.0", From 22c49a85353c28f8e6efca6ca9e0a87008a0b170 Mon Sep 17 00:00:00 2001 From: Emil Vanherp Date: Thu, 11 Nov 2021 22:55:40 +0100 Subject: [PATCH 2/2] Update async_timout to 4.0.0 Breaking change since the loop argument is not used anymore --- pydelijn/__init__.py | 2 +- pydelijn/api.py | 7 +++---- pydelijn/common.py | 5 ++--- setup.py | 2 +- tests/example.py | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pydelijn/__init__.py b/pydelijn/__init__.py index 7a3d21e..e4a1590 100644 --- a/pydelijn/__init__.py +++ b/pydelijn/__init__.py @@ -1,4 +1,4 @@ """Initialize the package.""" NAME = "pydelijn" -__version__ = "0.6.1" +__version__ = "1.0.0" diff --git a/pydelijn/api.py b/pydelijn/api.py index 7b4e46f..8af96a3 100644 --- a/pydelijn/api.py +++ b/pydelijn/api.py @@ -29,10 +29,9 @@ class Passages: """A class to get passage information.""" def __init__( - self, loop, stopid, maxpassages, subscriptionkey, session=None, utcoutput=None + self, stopid, maxpassages, subscriptionkey, session=None, utcoutput=None ): """Initialize the class.""" - self.loop = loop self.session = session self.stopid = str(stopid) self.stopname = self.stopid @@ -54,7 +53,7 @@ async def get_stopname(self): endpointstop = "{}haltes/{}/{}".format( BASE_URL, str(entitynum), str(self.stopid) ) - common = CommonFunctions(self.loop, self.session, self.subscriptionkey) + common = CommonFunctions(self.session, self.subscriptionkey) resultstop = await common.api_call(endpointstop) if resultstop is not None: self.stopname = "{}, {}".format( @@ -105,7 +104,7 @@ async def get_passages(self): if self.session is None: selfcreatedsession = True entitynum = self.stopid[:1] - common = CommonFunctions(self.loop, self.session, self.subscriptionkey) + common = CommonFunctions(self.session, self.subscriptionkey) passages = [] tzone = pytz.timezone("Europe/Brussels") diff --git a/pydelijn/common.py b/pydelijn/common.py index 696339d..6db8bc9 100644 --- a/pydelijn/common.py +++ b/pydelijn/common.py @@ -11,9 +11,8 @@ class CommonFunctions: """A class for common functions.""" - def __init__(self, loop, session, subscriptionkey): + def __init__(self, session, subscriptionkey): """Initialize the class.""" - self.loop = loop self.session = session self.subscriptionkey = subscriptionkey @@ -24,7 +23,7 @@ async def api_call(self, endpoint): if self.session is None: self.session = aiohttp.ClientSession() try: - async with async_timeout.timeout(5, loop=self.loop): + async with async_timeout.timeout(5): LOGGER.debug("Endpoint URL: %s", str(endpoint)) response = await self.session.get(url=endpoint, headers=headers) if response.status == 200: diff --git a/setup.py b/setup.py index f00f5b8..96f80f2 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ packages=setuptools.find_packages(exclude=('tests',)), install_requires=[ 'aiohttp>=3.6.2,<4.0', - 'async_timeout>=3.0.1,<4.0', + 'async_timeout>=4.0.0,<5.0', 'pytz>=2020.1' ], license='MIT', diff --git a/tests/example.py b/tests/example.py index 62e8e19..1b6272a 100644 --- a/tests/example.py +++ b/tests/example.py @@ -11,7 +11,7 @@ async def test_pydelijn(): maxpassages = 10 custom_session = aiohttp.ClientSession() delijndata = Passages( - LOOP, stopid, maxpassages, subscriptionkey, custom_session, True + stopid, maxpassages, subscriptionkey, custom_session, True ) await delijndata.get_passages() print_data(delijndata)