aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-18 16:50:46 +0100
committerGravatar jesopo2019-06-18 16:50:46 +0100
commit398bd7e117c5bec50b19f2c73e5d558b3b418b06 (patch)
tree20b6c3db3390f718cd19511917b83fe17ad39b5f
parent'location' wasn't the variable i thought it was (diff)
signature
use "city, state, country" for formatted location name when available
-rw-r--r--modules/location.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/location.py b/modules/location.py
index 2415d20b..3f1eef65 100644
--- a/modules/location.py
+++ b/modules/location.py
@@ -19,6 +19,19 @@ class Module(ModuleManager.BaseModule):
timezone = result["annotations"]["timezone"]["name"]
lat = result["geometry"]["lat"]
lon = result["geometry"]["lng"]
- name = result["formatted"]
+
+ name_parts = []
+ components = result["components"]
+ if "city" in components:
+ name_parts.append(components["city"])
+ if "state" in components:
+ name_parts.append(components["state"])
+ if "country" in components:
+ name_parts.append(components["country"])
+
+ if not name_parts:
+ name_parts.append(result["formatted"])
+
+ name = ", ".join(name_parts)
return {"timezone": timezone, "lat": lat, "lon": lon, "name": name}