import gc
from medea.auth import weatherAppId

weatherBaseUrl = "https://api.openweathermap.org/data/2.5/"


def createUrl(apiPath, getParams):
    url = weatherBaseUrl + apiPath + "?"
    url += "&".join(["{}={}".format(key, value) for key, value in getParams.items()])
    gc.collect()
    return url


def createCityUrl(city="Morecambe", country="uk"):
    return createUrl("forecast", dict(
        q="{},{}".format(city, country),
        appid=weatherAppId.decode('utf-8'),
    ))

@@ -125,25 +125,19 @@
 piPath, 
-getParams
+**k
 ):%0A    u
@@ -242,17 +242,9 @@
  in 
-getParams
+k
 .ite
@@ -336,43 +336,28 @@
 %22uk%22
+, **k
 ):%0A    
-return createUrl(%22forecast%22,
+params =
  dic
@@ -448,11 +448,182 @@
 '),%0A    
-)
+    cnt=8, # retrieves just 8x 3-hourly records by default (respecting limit of 8192 TLS record buffer)%0A    )%0A    params.update(k)%0A    return createUrl(%22forecast%22, **params
 )%0A

Allow passthrough of keyword arguments to weather URL, and set cnt=8 by default to limit JSON payload size