Skip to content

Commit

Permalink
replaced pkg_resources with importlib.resources
Browse files Browse the repository at this point in the history
This fixes a strange bug in bleak: hbldh/bleak#1132
  • Loading branch information
wilddom committed Mar 4, 2023
1 parent 6f826ab commit 9baa3e1
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 9baa3e1

Please sign in to comment.