Skip to content

Commit

Permalink
use rindex to remove urllib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nkraetzschmar committed Feb 6, 2024
1 parent 4aed562 commit 86df262
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libikawa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time
from bleak import BleakScanner, BleakClient, BleakError
from base64 import b64encode, b64decode
from urllib.parse import urlparse
from ikawa_pb2 import *

class Ikawa:
Expand Down Expand Up @@ -208,7 +207,11 @@ def crc16(data, init_value):

@staticmethod
def roast_profile_from_url(url):
data_base64 = urlparse(url).query
try:
index = url.rindex("?")
data_base64 = url[index+1:]
except ValueError:
data_base64 = url
data = b64decode(data_base64)
roast_profile = RoastProfile.FromString(data)
return roast_profile
Expand Down

0 comments on commit 86df262

Please sign in to comment.