Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced pkg_resources with importlib.resources #24

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pycycling/sterzo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import struct
import pkg_resources
import importlib.resources

sterzo_measurement_id = '347b0030-7635-408b-8918-8ff3949ce592'
sterzo_control_point_id = '347b0031-7635-408b-8918-8ff3949ce592'
Expand All @@ -22,7 +22,7 @@ async def enable_steering_measurement_notifications(self):
await self._activate_steering_measurements()

async def _activate_steering_measurements(self):
with pkg_resources.resource_stream(__name__, 'data/sterzo-challenge-codes.dat') as fp:
with importlib.resources.files(__package__).joinpath('data/sterzo-challenge-codes.dat').open('rb') as fp:
fp.seek(self._latest_challenge * 2, 1)
code_1 = int.from_bytes(fp.read(1), 'little')
code_2 = int.from_bytes(fp.read(1), 'little')
Expand Down