Skip to content

Commit

Permalink
Removal of jq dependancy (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
DurgNomis-drol authored Feb 3, 2021
1 parent a5cb30a commit 3f24e4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 18 additions & 4 deletions glocaltokens/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
import logging
import grpc
import jq
import json

from gpsoauth import perform_master_login, perform_oauth
Expand Down Expand Up @@ -123,7 +122,22 @@ def get_google_devices_json(self):
Returns a json of google devices with their
local authentication tokens
"""

def extract_devices(items):
"""
Replacement for jq
"""
devices = []
for item in items:
if item.local_auth_token != "":
device = {}
device['deviceName'] = item.device_name
device['localAuthToken'] = item.local_auth_token
devices.append(device)
return devices

homegraph = self.get_homegraph()
homegraph_json = json.loads(MessageToJson(homegraph))
devices = jq.compile('.home.devices[] | {deviceName, localAuthToken}').input(homegraph_json)
return devices.all()

devices = extract_devices(homegraph.home.devices)

return devices
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
'gpsoauth',
'grpcio',
'grpcio-tools',
'jq',
'simplejson',
'requests',
]
Expand Down

0 comments on commit 3f24e4d

Please sign in to comment.